[R] How to pass strings to functions? [once once more, now With content I hope...]

Gijs Plomp gplomp at brain.riken.jp
Thu Jul 8 12:23:36 CEST 2004


Dear expeRts,

I fail to succesfully pass strings to functions. It comes down to the 
observation that

 > plot(someVariable,anotherVariable)

works fine, but

 > x <- "someVariable"
 > y <- "anotherVariable"
 > plot(x,y)

does not.

Does this have something to do with the returned value of x being 
/"someVariable"/ and not /someVariable/, i.e. without the quotation 
marks? Is there any way to work around this?

Ultimately I'd like to make multiple graphs by looping throught the 
values in vectors. Something like:
 > var<-c(var1,var2...n)
 > for (v in var)
 >{
 > plot(var, x))
 >}

I've looked around for help on this but am stuck.

Hope you can help,
Gijs Plomp




More information about the R-help mailing list