Dear R users, Two questions: 1) Is there a way to simplify the mtext() line below ? beta=c(1,-1) m=5 plot(1) mtext( bquote(paste( beta == .(paste( "(", paste(beta, collapse=", "), ")" )) )), outer=TRUE,line=-3) 2) How do I get the embedded carriage return "\n" below to work, i.e for the text that follows it to appear on the next line? beta=c(1,-1) m=5 plot(1) mtext( bquote(paste( beta == .(paste( "(", paste(beta, collapse=", "), ") " )), "\n Expected # of true positives = ", .(m))), outer=TRUE, line=-3) Thanks in advance! Juan Pablo Lewinger, Ph.D. Department of Preventive Medicine Keck School of Medicine University of Southern California
Try this: m <- 5; beta <- c(-1, 1) plot(1, main = bquote(atop(beta == .(deparse(beta)), "Expected number of true positives" == .(m)))) On 7/31/06, Juan Lewinger <lewinger at usc.edu> wrote:> Dear R users, > > Two questions: > > 1) Is there a way to simplify the mtext() line below ? > > beta=c(1,-1) > m=5 > plot(1) > mtext( bquote(paste( beta == .(paste( "(", paste(beta, collapse=", "), ")" )) )), outer=TRUE,line=-3) > > 2) How do I get the embedded carriage return "\n" below to work, i.e for the text that follows it to appear on the next line? > > beta=c(1,-1) > m=5 > plot(1) > mtext( bquote(paste( beta == .(paste( "(", paste(beta, collapse=", "), ") " )), > "\n Expected # of true positives = ", .(m))), outer=TRUE, line=-3) > > Thanks in advance! > > Juan Pablo Lewinger, Ph.D. > Department of Preventive Medicine > Keck School of Medicine > University of Southern California > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Juan Lewinger <lewinger at usc.edu> writes:> Dear R users, > > Two questions: > > 1) Is there a way to simplify the mtext() line below ? > > beta=c(1,-1) > m=5 > plot(1) > mtext( bquote(paste( beta == .(paste( "(", paste(beta, collapse=", "), ")" )) )), outer=TRUE,line=-3) >The outer paste() is superfluous, but apart from that: Not really. You're specifying a nonstandard formatting of beta, "(1, -1)" so you also need to give all details. If you can live with a slightly different format, try mtext( bquote(beta == .(deparse(beta) ) ), outer=TRUE,line=-3) and in fact, mtext(bquote( beta == .(substring(deparse(beta), 2)) ), outer=TRUE,line=-3) will strip off the leading "c" and give you what you want, but only slightly less cryptically.> 2) How do I get the embedded carriage return "\n" below to work, i.e for the text that follows it to appear on the next line? > > beta=c(1,-1) > m=5 > plot(1) > mtext( bquote(paste( beta == .(paste( "(", paste(beta, collapse=", "), ") " )), > "\n Expected # of true positives = ", .(m))), outer=TRUE, line=-3) > > Thanks in advance! > > Juan Pablo Lewinger, Ph.D. > Department of Preventive Medicine > Keck School of Medicine > University of Southern California > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907