Skip to content
Prev 246197 / 398503 Next

Please, need help with a plot

Victor F Seabra <vseabra <at> uol.com.br> writes:
This is a little bit more 'magic' than I would like, but seems
to work. Perhaps someone else can suggest a cleaner solution.

ages <- gsub("[^0-9]+","",table1$var1)
rel <- gsub("age\\s*([=<>]+)\\s*[0-9]+","\\1",table1$var1,perl=TRUE)

with(table1,plot(var2,1:11,xlim=c(0,20),pch=20))
invisible(with(table1,
     mapply(function(x,y,a,r) {
       text(x=x,y=y,
            switch(r,
                   `<=`=bquote(age <= .(a)),
                   `<`=bquote(age < .(a)),
                   `>=`=bquote(age >= .(a))),
            pos=4)},
       var2,1:11,ages,rel)))