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

bogdan romocea br44114 at gmail.com
Wed Jul 12 18:03:53 CEST 2006


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
>



More information about the R-help mailing list