If I understand your question correctly, you can use:
>
df <- data.frame(Resist = 1:10, ExpnsnCoeff = 1:10, Voltage = 1:10)
>
DataColumn <- "Resist"
>
MatrixColumn <- "ExpnsnCoeff"
>
ScalarColumn <- "Voltage"
>
df[[DataColumn]] # Same as df$Resist
[1]
1 2 3 4 5 6 7 8 9 10
Hope
this helps,
Rich.
mangosolutions
S-PLUS
& R Consulting & Training
Tel
+44 1249 467 467
Fax +44
1249 467 468
From: Santosh
[mailto:santosh2005@gmail.com]
Sent: 22 January 2007 06:54
To: s-news@lists.biostat.wustl.edu
Subject: [S] Indirect references
in SPLUS
Dear SPlus Users,
Is there a way to work with indirect references in SPlus?
For example,
DataColumn <- "Resist"
MatrixColumn <- "ExpnsnCoeff"'
ScalarColumn <- "Voltage"
As I don't know the syntax, I would like illustrate using the examples given
below.
In conventional SPLUS notation, if "df" is a generic dataframe that
consists of vectors
"Resist", "ExpnsnCoeff", "Voltage",
"df$Resist", "df$ExpnsnCoeff", "df$Voltage"
notation may be used to for data handling in respective vectors of the data
frame.
Instead of the above notation, I would like to use an indirect reference like:
Assuming that the syntax to provide indirect references is curly braces, e.g.
${DataColumn},
"df${DataColumn}" indirectly accesses the vector
"df$Resist";
similarly "df${MatrixColumn}" calls
"df$ExpnsnCoeff" vector indirectly, and so on..
Hope the above question is clear; please do feel free to ask if you have any
additional questions.
Regards,
Santosh