[R] Manipulating Matricies

Petr Pikal petr.pikal at precheza.cz
Fri Jul 26 13:32:28 CEST 2002


From:           	Petr Pikal <petr.pikal at precheza.cz>
To:             	jleach at mail.ocis.net
Subject:        	Re: [R] Manipulating Matricies
Date sent:      	Fri, 26 Jul 2002 13:26:29 +0200



On 25 Jul 2002 at 15:22, Jason C. Leach wrote:

> hi,
> 
> 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

see

?as.matrix

and [] parentheses help

e.g.

my.matrix <- as.matrix(daf[,c(1:3,5,9)])

will construct a matrix from colunms 1-3,5 and 9

and similar approach you can use on matrices

> matrix, how can I add and remove columns?

my.matrix <- my.matrix[,-5]

will give you matrix without column 5

> 
> Thanks,
> j.
> 
> 
> -- 
> ......................
> ..... Jason C. Leach
> .. 
> 
> Current PGP/GPG Key ID: 43AD2024 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> -. -.-.-.-.- 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
> _. _._._._._
Petr Pikal
petr.pikal at precheza.cz
p.pik at volny.cz


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 mailing list