I think this is a super quick thing, but I figured I\'d ask since I can\'t for the life of me remember how to do it...
Suppose, I have a data.frame (call it, DF
DF$foo[1]
tries to return the first element of the column named foo
(which doesn't exist). You want DF[foo[1]]
.
subset(DF, select=foo[3])
Blah
1 0.814939149951
2 -0.800644571486
3 -0.424080059851
4 1.012792429940
5 1.291888735720
6 0.642523425131
7 0.537486547429
8 0.315031122082
9 -0.296439716108
10 0.372453578695
Is this what you want?
DF[ ,foo][1]
Ah, Joshua posted while I was typing... You can aslo select regions of the columns, eg:
DF[1:3,foo][1]