Hi,
Use %in% instead of ==.
HTH,
Jorge.-
On Thu, Jan 12, 2012 at 9:36 PM, 忬£ <> wrote:
> Hi all
> I have a question about "subset" function.
>
>
> > dat
> id x1 x2 x3
> 1 a 1 11 111
> 2 b 2 22 222
> 3 c 3 33 333
> 4 d 4 44 444
>
>
> > subset(dat,id==c("a","c"))
> id x1 x2 x3
> 1 a 1 11 111
>
> > subset(dat,id==c("a","d"))
> id x1 x2 x3
> 1 a 1 11 111
> 4 d 4 44 444
>
>
> >From the above, if I choose id=a,c, the result is wrong,but if I choose
> id=a,d, the result is right.
>
>
> What's the reason for it?
>
>
>
>
> Many thanks!
>
>
>
>
> My best
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] 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]]
______________________________________________
[email protected] 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.