Re: [R] Turning Data Frame Columns into Vectors

2011-10-15 Thread Daniel Malter
You access columns of a data.frame by column indices as in: X[ ,1], X[ ,2], etc. The index before the comma would stand for the row if you wanted to restrict those. The index after the comma captures the column. That said, you typically would not extract rows from the data frame but draw directly

[R] Turning Data Frame Columns into Vectors

2011-10-15 Thread jawbonemurphy
Hi, I converted an Excel file into a .txt file X.txt with no header ( http://r.789695.n4.nabble.com/file/n3908157/X.txt X.txt ) and imported it with: X - read.table(/Users/johnlogandurland/Desktop/X.txt, header=FALSE). What I would like to do is to make the first column into a factors vector,

Re: [R] Turning Data Frame Columns into Vectors

2011-10-15 Thread jawbonemurphy
Hi Daniel, Thanks for the reply, that was the one missing piece! I had been trying to use the tapply() function, but was getting an error message about unequal length until now. I wrote: VAL_mean_xpart - tapply(X[ ,2], PARTF, mean) and got the column 2 means by factors just as I had hoped.