[R] Re: [S] extracting a matrix from a data frame

John Maindonald john.maindonald at anu.edu.au
Sun Mar 25 00:04:06 CET 2001


Try as.matrix(df)
where df may be subsetted.


> From: "Chris Evans" <chris1 at psyctc.org>
> To: s-news at lists.biostat.wustl.edu
> Date: Sat, 24 Mar 2001 19:25:32 -0000
> Content-transfer-encoding: 7BIT
> Subject: [S] extracting a matrix from a data frame
> 
> I'm a researcher who often has to do my own statistics for various 
> reasons so apologies if this and two other questions are pretty low 
> level.
> 
> I've just found the apply function and the array objects brilliant for 
> speedy work on some 3 mode rating data.  The data had to be 
> imported from an SPSS data set so my first silly question is how I 
> should extract a matrix from a data frame.  I wanted some 
> contiguous columns in the frame to become a matrix.  I ended up 
> using c to concatenate the variables, listed laboriously, after 
> attaching the frame.  I must be missing something in the 
> subscripting of data frames musn't I?  Would someone tell me or 
> point me to right place?
> 
> TIA,
> 
> 
> Chris
> 
> Chris Evans <chris at psyctc.org>
> Consultant Psychiatrist in Psychotherapy,
> Rampton Hospital; Associate R&D Director,
> Tavistock & Portman NHS Trust;
> Hon. SL Institute of Psychiatry
> *** My views are my own and not representative 
> of those institutions ***
> ---------------------------------------------------------------------
> This message was distributed by s-news at lists.biostat.wustl.edu.  To
> unsubscribe send e-mail to s-news-request at lists.biostat.wustl.edu with
> the BODY of the message:  unsubscribe s-news
> 
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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