[R] read a file into a matrix

Benilton Carvalho bcarvalh at jhsph.edu
Fri Nov 20 19:30:06 CET 2009


I can't think of anything that is already built in.

But you can always:

read.as.matrix <- function(...) as.matrix(read.delim(...))

and now you get one step only ;-)

b

On Nov 20, 2009, at 4:01 PM, Peng Yu wrote:

> On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou
> <mailinglist.honeypot at gmail.com> wrote:
>>> read.delim gives me a data.frame. Is there a function that can  
>>> return
>>> the result in a matrix rather than data.frame?
>>
>> m <- as.matrix(read.delim(..))
>
> I knew this approach. But this takes an extra step. Is there a command
> that read a file directly into a matrix?
>
> Regards,
> Peng
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list