Re: [R] evaluate variable within expression - how?
Hi Mark, Try also: plot(1:10) text(2, 5, "Some text", font = 2) HTH, Jorge On Sun, Feb 14, 2010 at 11:36 AM, Mark Heckmann <> wrote: > # I want to plot bold text. The text should depend on a variable > containing a character string. > > plot.new() > text(.5, .5, expression(bold("Some text"))) > > # now I would like to do the same replacing "some text" by a variable. > > plot.new() > myText <- "some text" > text(.5, .5, expression(bold(myText))) > > # This obviouyls does not work. > # How can I combine substitute, parse, paste etc. do get what I want? > # And could someone add a brief explanation what happens, as I find > parse, expression, deparse, substitute etc. not easy to understand. > > Thanks, > Mark > > > Mark Heckmann > Dipl. Wirt.-Ing. cand. Psych. > Vorstraße 93 B01 > 28359 Bremen > Blog: www.markheckmann.de > R-Blog: http://ryouready.wordpress.com > > > > > >[[alternative HTML version deleted]] > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] evaluate variable within expression - how?
Try text(.5, .5, bquote(bold(.(myText -Peter Ehlers Mark Heckmann wrote: # I want to plot bold text. The text should depend on a variable containing a character string. plot.new() text(.5, .5, expression(bold("Some text"))) # now I would like to do the same replacing "some text" by a variable. plot.new() myText <- "some text" text(.5, .5, expression(bold(myText))) # This obviouyls does not work. # How can I combine substitute, parse, paste etc. do get what I want? # And could someone add a brief explanation what happens, as I find parse, expression, deparse, substitute etc. not easy to understand. Thanks, Mark ––– Mark Heckmann Dipl. Wirt.-Ing. cand. Psych. Vorstraße 93 B01 28359 Bremen Blog: www.markheckmann.de R-Blog: http://ryouready.wordpress.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] evaluate variable within expression - how?
Hi, Try with bquote, plot.new() myText <- "some text" text(.5, .5, bquote(bold(.(myText basically, bquote( .(myText) ) performs the substitution before applying bold() (see ?bquote). HTH, baptiste On 14 February 2010 17:36, Mark Heckmann wrote: > # I want to plot bold text. The text should depend on a variable > containing a character string. > > plot.new() > text(.5, .5, expression(bold("Some text"))) > > # now I would like to do the same replacing "some text" by a variable. > > plot.new() > myText <- "some text" > text(.5, .5, expression(bold(myText))) > > # This obviouyls does not work. > # How can I combine substitute, parse, paste etc. do get what I want? > # And could someone add a brief explanation what happens, as I find > parse, expression, deparse, substitute etc. not easy to understand. > > Thanks, > Mark > > ––– > Mark Heckmann > Dipl. Wirt.-Ing. cand. Psych. > Vorstraße 93 B01 > 28359 Bremen > Blog: www.markheckmann.de > R-Blog: http://ryouready.wordpress.com > > > > > > [[alternative HTML version deleted]] > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] evaluate variable within expression - how?
# I want to plot bold text. The text should depend on a variable containing a character string. plot.new() text(.5, .5, expression(bold("Some text"))) # now I would like to do the same replacing "some text" by a variable. plot.new() myText <- "some text" text(.5, .5, expression(bold(myText))) # This obviouyls does not work. # How can I combine substitute, parse, paste etc. do get what I want? # And could someone add a brief explanation what happens, as I find parse, expression, deparse, substitute etc. not easy to understand. Thanks, Mark Mark Heckmann Dipl. Wirt.-Ing. cand. Psych. Vorstraße 93 B01 28359 Bremen Blog: www.markheckmann.de R-Blog: http://ryouready.wordpress.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.