[R] Manipulating Matricies
ramasamy at stats.ox.ac.uk
Fri Jul 26 12:42:04 CEST 2002
I am sure this is in the R help/manuals somewhere. Suppose your matrix, data
is of dim 10 by 5 and you want to extract the the columns 1,2,4. Then you
use newdata <- data[ , c(1,2,4). Now you changed your mind and want to get
rid of column 1, then you use newdata2 <- data[ , -1]. If you had used
newdata instead of newdata2, then you newdata will be overwritten instead.
For rows you use data[ j , ] where j are the number(s) of rows you want to
extract. And use - j for the subset of rows you want to get rid off. I would
suggest you have a look at the manual again.
----- Original Message -----
From: "Jason C. Leach" <jleach at mail.ocis.net>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, July 25, 2002 11:22 PM
Subject: [R] Manipulating Matricies
> If I have a table of data, from read.table or scan how can I
> extract various columns to create a matrix? And once I have the
> matrix, how can I add and remove columns?
> ..... Jason C. Leach
> Current PGP/GPG Key ID: 43AD2024
> r-help mailing list -- Read
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help