On Tue, 7 May 2002, hkimscil wrote:> Hello all - > > If I want to put mean value of a matrix into the title or subtitle of a graph, how would I do this? For example, in a set of commands like below, > > > m.mean<-mean(m) > > gplot (m, thresh=m.mean) > > title (main="A2. Block Density of Matrix m\nplotted based on MDS", > + sub="lines below mean density (**0.435**) suppressed") > > I want to ask [R] to put the mean value (whatever it is, calulated as > m.mean) into subtitle automatically, instead of my writing **0.435**. > > Is it possible?Yes, it's even easy. title(sub=paste("lines below mean density (",m.mean,") suppressed",sep="")) -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello all - If I want to put mean value of a matrix into the title or subtitle of a graph, how would I do this? For example, in a set of commands like below,> m.mean<-mean(m) > gplot (m, thresh=m.mean) > title (main="A2. Block Density of Matrix m\nplotted based on MDS",+ sub="lines below mean density (**0.435**) suppressed") I want to ask [R] to put the mean value (whatever it is, calulated as m.mean) into subtitle automatically, instead of my writing **0.435**. Is it possible? Thanks! -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> If I want to put mean value of a matrix into the title or subtitle of a graph, how would I do this? For example, in a set of commands like below, > > > m.mean<-mean(m) > > gplot (m, thresh=m.mean) > > title (main="A2. Block Density of Matrix m\nplotted based on MDS", > + sub="lines below mean density (**0.435**) suppressed") >To get the whole expression into the subtitle you could use paste(). title (main="A2. Block Density of Matrix m\nplotted based on MDS", sub=paste("lines below mean density", m.mean, "suppressed")) Andrea> I want to ask [R] to put the mean value (whatever it is, calulated as m.mean) into subtitle automatically, instead of my writing **0.435**. > > Is it possible? > > Thanks! > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Andrea Peters wrote:> > > If I want to put mean value of a matrix into the title or subtitle of a graph, how would I do this? For example, in a set of commands like below, > > > > > m.mean<-mean(m) > > > gplot (m, thresh=m.mean) > > > title (main="A2. Block Density of Matrix m\nplotted based on MDS", > > + sub="lines below mean density (**0.435**) suppressed") > > > To get the whole expression into the subtitle you could use paste(). > > title (main="A2. Block Density of Matrix m\nplotted based on MDS", > sub=paste("lines below mean density", m.mean, "suppressed"))You might also want to introduce some simple formatting. From R-1.5.0 you can use the "sprintf" function rather than "paste" to do title(main = "A2. Block Density of Matrix m\nplotted based on MDS", sub = sprintf("lines below mean density (%.3f) suppressed", m.mean)) Jonathan. -- Jonathan Rougier Science Laboratories Department of Mathematical Sciences South Road University of Durham Durham DH1 3LE tel: +44 (0)191 374 2361, fax: +44 (0)191 374 7388 http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> + sub="lines below mean density (**0.435**) suppressed") > > I want to ask [R] to put the mean value (whatever it is, calulated as m.mean) into subtitle automatically, instead of my writing **0.435**. > > Is it possible?Yes! sub=paste("lines below mean.density (**",mean.m,"**) suppressed",sep="") Sundar -- Sundar Dorai-Raj, Ph.D. Statistical Methods Engineer PDF Solutions, Inc. Richardson TX (972) 889-3085 x216 (214) 392-7619 cell sundar.dorai-raj at pdf.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._