[R] About reading data into R

Gabor Grothendieck ggrothendieck at myway.com
Thu Mar 11 06:15:35 CET 2004


read.table uses scan.  Issue the command

   read.table

to see the R source code.

You can compare timings with your data set like this:

   gc(); system.time( z1 <- read.table(myfile) )
   gc(); system.time( z2 <- scan(myfile) )

(where you may need to fix up the function calls above
to reflect any additional arguments needed to read your 
dataset correctly).  

---
Date:   Wed, 10 Mar 2004 22:42:45 -0600 (CST) 
From:   Rui Song <rsong at cs.wisc.edu>
To:   Gabor Grothendieck <ggrothendieck at myway.com> 
Cc:   <rsong at cs.wisc.edu>, <R-help at R-project.org> 
Subject:   RE: [R] About reading data into R 

 
Thanks for your reply, I chose to use scan here. So can I ask another
question, which function works faster, scan or read.table?

Thanks,

Rui

On Tue, 9 Mar 2004, Gabor Grothendieck wrote:

>
>
> scan has no problem with blank lines. read.table has
> an argument that controls how it handles blank lines
> and the default setting is to ignore them.
>
>
> ---
> Date: Mon, 8 Mar 2004 20:27:48 -0600 (CST)
> From: Rui Song <rsong at cs.wisc.edu>
> To: <R-help at R-project.org>
> Subject: [R] About reading data into R
>
>
> I have a problem about reading data into R. There is a "\n"
> between each pair of data, like:
>
> -155.65
>
> -155.77
>
> -155.40
>
> -155.46
>
> -155.52
>
> -155.34
>
> ...
> Could anyone tell me how to read in such data? Thanks!
>
> Rui
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list