[R] Help with getting values from string

renu.s7 renu.selvamani at gmail.com
Thu May 3 12:39:48 CEST 2012


Hi All,

I have a doubt. I used macros and i try to pass a value to a macro by
concatenating a bunch of strings. But it does not seem to work. Please help.
I have written down my code and the error message please tell me how to pass
the value that a string points to. Thanks in advance

#macro defined
machist_occ_kgfs<-defmacro(a,qnu_occ,b,qnl_occ,expr={with(subset(an_ind_data_fin,income_source==a
& region_id==b & normalised_income>qnl_occ &
normalised_income<qnu_occ),hist(normalised_income,main=paste(a,b,sep="
")))})
#macro called
machist_occ_kgfs(occ,paste("qnu",ri,occ,collapse="",sep=""),ri,paste("qnl",ri,occ,collapse="",sep=""))

Error in hist.default(normalised_income, main = paste(occ, ri, sep = " "), 
: 
  hist.default: pretty() error, breaks=
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

The thing is paste("qnu",ri,occ,collapse="",sep="") returns the value
"qnu1Business__Others" but the variable - qnu1Business__Others contains an
integer value which i need to be passed on to the macro. Hope i have made
myself clear. Thanks in advance for your help

--
View this message in context: http://r.789695.n4.nabble.com/Help-with-getting-values-from-string-tp4605632.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list