Re: [R] read a file into a matrix

2009-11-20 Thread Steve Lianoglou

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(..))

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@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.


Re: [R] read a file into a matrix

2009-11-20 Thread Peng Yu
On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou
mailinglist.honey...@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@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.


Re: [R] read a file into a matrix

2009-11-20 Thread Benilton Carvalho

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.honey...@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@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.


__
R-help@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.


Re: [R] read a file into a matrix

2009-11-20 Thread David Winsemius


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


On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou
mailinglist.honey...@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?


You can wrap matrix() around a scan() call. An example might prompt  
more specifics.


You also could easily modify read.delim (which is after all a wrapped  
scan call) to create a matrix rather than a dataframe.


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@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.


Re: [R] read a file into a matrix

2009-11-20 Thread jim holtman
What is wrong with the extra step?  Is it taking too much time (you
did not specify that), is it taking too much memory?  How many times
are you going to be doing it?  If not many, then may be it is OK.  You
have to quantify what you are asking for.  It may take longer to send
a message to R-Help and get a response than to just read the file in
and process it.

On Fri, Nov 20, 2009 at 1:01 PM, Peng Yu pengyu...@gmail.com wrote:
 On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou
 mailinglist.honey...@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@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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
R-help@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.