Jorge, thanks for your suggestions, but they give the same (empty) result:

> RECinf<-subset(REC2,  INFECTION=="Infected")
> head(RECinf)
[1] RINGNO    year      ccFLEDGE  rec2012   binage    INFECTION all.rsLD
<0 rows> (or 0-length row.names)

but David's suggestion worked! :

> RECinf<-REC2[REC2$INFECTION=="Infected ",]
> head(RECinf)
    RINGNO  year ccFLEDGE rec2012 binage INFECTION   all.rsLD
2  BX23298 Y2003        6       1    juv Infected  -6.1938776
4  BT53646 Y2003        5       2     ad Infected  -4.1938776
7  BT53248 Y2003        6       1     ad Infected  -2.1938776
11 BY75833 Y2004        5       0     ad Infected  -4.6574803
13 BX23067 Y2004        6       0     ad Infected  -3.6574803
17 BX24240 Y2004        6       0     ad Infected   0.3425197


still not sure why the subset() function didn't work, though.

Thanks for your help!



Katarzyna Kulma

PhD Student
Department of Ecology and Genetics
Institute of Ecology and Evolution/Animal Ecology
Uppsala University
Norbyvägen 18D
SE-752 36 Uppsala, Sweden

email: katarzyna.ku...@ebc.uu.se
Tel.+46 (0)18 471 2672
Fax.+46 18 471 6484


On 3 May 2013 13:13, David Kulp <dk...@fiksu.com> wrote:

> You have an extra space in the INFECTION factors.
>
> Use REC2[REC2$INFECTION=="Infected ",]
> or
> subset(REC2, INFECTION=="Infected ")
>
> No need to use which here.
>
> On May 3, 2013, at 5:48 AM, Katarzyna Kulma wrote:
>
> > Hi everyone,
> >
> > I know there have been several requests regarding subsetting before, but
> > none of them really helps with my problem:
> >
> > I'm trying to subset only infected individuals from the REC2 data.frame:
> >
> >> str(REC2)
> > 'data.frame':    362 obs. of  7 variables:
> > $ RINGNO   : Factor w/ 370 levels "BL17546","BL17577",..: 78 81 67 41 58
> > 66 17
> > $ year     : Factor w/ 8 levels "Y2002","Y2003",..: 1 2 1 2 1 1 2 1 1 3
> ...
> > $ ccFLEDGE : int  6 6 6 5 6 7 6 7 6 5 ...
> > $ rec2012  : int  2 1 2 2 1 2 1 1 1 0 ...
> > $ binage   : Factor w/ 2 levels "ad","juv": 1 2 1 1 1 1 1 1 1 1 ...
> > $ INFECTION: Factor w/ 2 levels "Infected ","Uninfected ": 2 1 2 1 2 2 1
> 2
> > 2 1 ...
> > $ all.rsLD : num  -4.62 -6.19 -3.62 -4.19 -2.62 ...
> >
> > using either
> >
> > RECinf<-REC2[which (REC2$INFECTION=="Infected"),]
> >
> > or
> >
> > RECinf<-subset(REC2,  INFECTION=="Infected")
> >
> > in both cases I get empty data frame (0 observations):
> >
> >> str(RECinf)
> > 'data.frame':    0 obs. of  7 variables:
> > $ RINGNO   : Factor w/ 370 levels "BL17546","BL17577",..:
> > $ year     : Factor w/ 8 levels "Y2002","Y2003",..:
> > $ ccFLEDGE : int
> > $ rec2012  : int
> > $ binage   : Factor w/ 2 levels "ad","juv":
> > $ INFECTION: Factor w/ 2 levels "Infected ","Uninfected ":
> > $ all.rsLD : num
> >
> > When subsetting, R doesn't return any warning or error message. Besides,
> I
> > used same codes many times before and they worked perfectly well. Any
> ideas
> > why this case is different?
> >
> > Thanks for your help,
> > Kasia
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org 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.
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to