[R] subscripting issues
marc_schwartz at comcast.net
Thu Jan 25 17:44:18 CET 2007
On Thu, 2007-01-25 at 11:04 -0500, ablukacz wrote:
> Dear All,
> I have a very simple problem.
> I have a matrix called Predictors with headers X0...X24
>  79 25
> X0 X1 X2 X3 X4 X5 X6
> 1 13.741200 12.148036 11.909435 11.671669 11.238207 10.864697 10.566351
> 2 10.240200 11.883900 11.529400 11.515050 11.411640 11.105800 10.813457
> I would like to take each row and all the corresponding columns with out
> the header.
> I tried Predictors[1,1:25] but that retains the headers.
> Any suggestions.
The column names of X0, etc. suggest that Predictors is a data frame
created by the use of one of the read.table() family of functions, not a
matrix. An important difference depending upon what you intend to do
with the data.
However, in both cases, you can generally manipulate the data as if the
headers were not present. In other words, most R functions will take the
numeric values and act in a predictable (sorry for the pun) fashion.
Think of the output above as if the column names X0 through X6 were A
through G in a spreadsheet. They are simply labels, not part of the data
itself. The same goes for the row names of 1 and 2.
More information about the R-help