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

2012-03-08 Thread Rui Barradas
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

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

2012-03-08 Thread rgm
Hi there, I'm having some difficulty using a variable to call a column from a matrix. I am trying to analyze several columns against each other using a for loop in the following way: x<-data.frame(A=1:5,B=6:10,C=11:15,D=16:20,E=21:26) titles<-c("A","B","C","E") for( i in 1:length(titles)){ y<-t