[R] Calling a column from a matrix using a variable

Rui Barradas rui1174 at sapo.pt
Thu Mar 8 21:01:06 CET 2012


Hello,

Try

x<-data.frame(A=1:5,B=6:10,C=11:15,D=16:20,E=21:26)
titles<-c("A","B","C","E")

y <- "C"
x[ , y]

Hope this helps,

Rui Barradas


--
View this message in context: http://r.789695.n4.nabble.com/Calling-a-column-from-a-matrix-using-a-variable-tp4457466p4457509.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list