hi all i have a simple question: lets assume that i can enter a variable (a) equal to some value, say 100. obviously a could be any value. i would like to create a plot with a main heading as hi all "some writing" + a how would own create a string by combining a string with a numeric variable? hope the question is not too confusing. e.g. say a=5 then i want something like plot(x, main="some writing"+a) this obviously does not work since the syntax is incorrect. thankful for your replies.
Use paste(), which coerces non-character arguments into characters before concatenating them. Andy> From: allan clark > > hi all > > > i have a simple question: > > lets assume that i can enter a variable (a) equal to some value, say > 100. obviously a could be any value. i would like to create a > plot with > a main heading as > hi all > > > "some writing" + a > > how would own create a string by combining a string with a numeric > variable? > > hope the question is not too confusing. > > e.g. say a=5 then i want something like plot(x, main="some > writing"+a) > > this obviously does not work since the syntax is incorrect. > > thankful for your replies. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
?paste allan clark <allan at stats.uct.ac.za> Sent by: r-help-bounces at stat.math.ethz.ch 09/29/2004 07:58 AM To: Rhelp <r-help at stat.math.ethz.ch> cc: Subject: [R] R: string connections hi all i have a simple question: lets assume that i can enter a variable (a) equal to some value, say 100. obviously a could be any value. i would like to create a plot with a main heading as hi all "some writing" + a how would own create a string by combining a string with a numeric variable? hope the question is not too confusing. e.g. say a=5 then i want something like plot(x, main="some writing"+a) this obviously does not work since the syntax is incorrect. thankful for your replies. ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Hi Allan, look at ?paste, e.g., a <- 10 plot(1:10, 1:10, main=paste("The value of a is", a)) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/396887 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm ----- Original Message ----- From: "allan clark" <allan at stats.uct.ac.za> To: "Rhelp" <r-help at stat.math.ethz.ch> Sent: Wednesday, September 29, 2004 1:58 PM Subject: [R] R: string connections> hi all > > > i have a simple question: > > lets assume that i can enter a variable (a) equal to some value, say > 100. obviously a could be any value. i would like to create a plot > with > a main heading as > hi all > > > "some writing" + a > > how would own create a string by combining a string with a numeric > variable? > > hope the question is not too confusing. > > e.g. say a=5 then i want something like plot(x, main="some > writing"+a) > > this obviously does not work since the syntax is incorrect. > > thankful for your replies. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >