Why do you need to use the get() command? If you want to access a
column of a known data frame by name:
R> fakedata <- data.frame(A=1:3, B=letters[8:10], C=runif(3))
R> fakedata["A"]
A
1 1
2 2
3 3
If you're trying to access a data frame by name, then you do need get,
but can then subset normally.
R> myname <- "fakedata"
R> get(myname)["A"]
A
1 1
2 2
3 3
In other words, either you're using the wrong tool for the job, or you
haven't clearly explained your problem.
Sarah
On Thu, Mar 6, 2014 at 1:33 PM, Brian Smith <bsmith030465 at gmail.com>
wrote:> Hi,
>
> I was trying to get at some values from 'data' using the get
function. Here
> is my code:
>
>> class(data)
> [1] "data.frame"
>> class(data$gender.factor)
> [1] "factor"
>> head(data$gender.factor)
> [1] Male Female Male Female Male Female
> Levels: Male Female
>> xx <- get("data$gender.factor")
> Error in get("data$gender.factor") :
> object 'data$gender.factor' not found
>> traceback()
> 2: get("data$gender.factor")
> 1: get("data$gender.factor")
>
>
> What should I be doing to read in the values using the get command?
>
> thanks!
>
--
Sarah Goslee
http://www.functionaldiversity.org