Re: [R] Excluding columns from dataframe and selecting row records

From: Logan Lewis <lr_at_proxc.net>
Date: Sun 17 Sep 2006 - 20:27:02 GMT

Miltinho,

On Sun, Sep 17, 2006 at 05:08:29PM -0300, Milton Cezar wrote:
> Dear R-friends,
>
> I have to simple questions. First I would like to exclude some
columns from a dataframe and after I need select rows that satisfy some conditions.
> My data frame looks like
>
> Region Species Bodysize Weigth Age
> Africa Sp1 10.2 20 2
> Africa Sp2 12.2 12 2
> Africa Sp3 15.3 18 3
> Africa Sp4 11.5 40 4
> Brazil Sp1 10.2 40 3
> Brazil Sp2 22.2 32 2
> Brazil Sp3 12.3 28 3
> Brazil Sp4 21.5 30 5
>
> And I need for example only "columns" Bodysize Weigth and Age when
Region=="Brazil" AND Species=="Sp2" AND Age>=3
>

The "subset" command should suit your needs: subset(dataframe, Region=="Brazil" && Species=="Sp2" && Age>=3,select = c("Bodysize","Weigth","Age"))

See help(subset) for more info.

Regards,
Logan



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 and provide commented, minimal, self-contained, reproducible code. Received on Mon Sep 18 06:30:10 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 Sun 17 Sep 2006 - 22:30:05 GMT.

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