Re: [R] Is it possible to only read a subset by read.table ?

From: Steve Miller <steve.miller_at_jhu.edu>
Date: Thu 13 Jul 2006 - 07:40:27 EST


You could also use Perl/Python/Ruby to pipe the data to R, e.g. msci <- read.table(pipe("python /steve/python/msciintl.py"),sep=",",header=T, as.is=T)

This is a very reasonable way to exploit the data munging capabilities of the agile languages. Of course, better still is to query the data into R from a relational database.

Steve Miller

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of bogdan romocea Sent: Wednesday, July 12, 2006 11:04 AM
To: D.Vonka@UvT.nl
Cc: r-help
Subject: Re: [R] Is it possible to only read a subset by read.table ?

It's possible and straightforward (just don't use R). IMHO the GNU Core Utilities
http://www.gnu.org/software/coreutils/
plus a few other tools such as sed, awk, grep etc are much more appropriate than R for processing massive text files. (Get a good book about UNIX shell scripting. On Windows you can use Services For Unix or Cygwin.)

Also, here's an example that you could adapt to print the males from your data set to a separate file, which you could then import in R. #---print specific lines to another file--- suffix=_JAN06
for F in `ls *data*`
do
  echo $F
  sed -n -e '/2006-01-[0-9][0-9]/p' $F > ${F}${suffix} done

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of David Vonka
> Sent: Wednesday, July 12, 2006 8:37 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Is it possible to only read a subset by read.table ?
>
> Hello,
>
> is it possible to do something like
>
> DATA <- read.table(file="blabla.dat",subset=(sex=="male")),
>
> i.e. make R read only a subset of a csv file ?
> I think it would be useful in case of very big datasets,
> but I can't find such a feature.
>
> Thanks for an answer,
> David Vonka
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 13 07:49:17 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 13 Jul 2006 - 10:17:46 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.