You can use "[[", I think, as in

basin.param[[string.variable]]

or, eqivalently for a data frame

basin.param[, string.variable]

-roger

Dewez Thomas wrote:
Hi all,

I haven't been able to find how to assess a variable who's name is
constructed with paste. The problem is following: In a data frame, there are
12 columns whose title vary only by a digit, all other part being equal. I
would like to compute a operation on a subset these variables and parse them
in turn.

the data frame "basin.param" contains columns called ratio1, ratio2,
ratio3...
in each of these ratios I want to retain only values above 0. This could be
put like this

crit<- which(basin.param$ratio1 > 0)
basin.param$ratio1[crit] + basin.param$val[crit]

OK, so what if I want to increment from ratio1 to ratio3 automatically and
return the value of the variable represented by the string? (does this make
sense?)
# Create the variable name for (i in 1:3){
string.variable <- paste("basin.param$ratio", index, sep="")
# What is the instruction to interpret the string.variable value ???
}


Cheers

Thomas
***
Le contenu de cet e-mail et de ses pièces jointes est destin...{{dropped}}

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to