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

Steve Miller steve.miller at jhu.edu
Wed Jul 12 23:40:27 CEST 2006


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 at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of bogdan romocea
Sent: Wednesday, July 12, 2006 11:04 AM
To: D.Vonka at 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 at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of David Vonka
> Sent: Wednesday, July 12, 2006 8:37 AM
> To: r-help at 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 at 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 at 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



More information about the R-help mailing list