[R] Interpolating variables into quoted strings

Dirk Eddelbuettel edd at debian.org
Thu Dec 20 00:39:54 CET 2001


On Wed, Dec 19, 2001 at 03:56:30PM -0600, William_Fitchen at oxy.com wrote:
> In perl I could write:
> 	
> 	$name = "John";
> 	print STDOUT "Hi $name, how's it going";
> 
> which would output the following:
> 
> 	Hi John, how's it going?
> 
> Is there a function that allows a variable containing a character string or
> numeric to be interpolated into a quoted character string?  Any help would
> be greatly appreciated!

name <- "John"
cat(paste("Hi", name, "how's it going\n"))


You might want to look at the "An Introduction to R" manual shipped with R,
it covers paste() in the "Character vectors" section.

Dirk

-- 
Good judgment comes from experience; experience comes from bad judgment. 
							    -- F. Brooks
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list