[R] make a right subset!
ruipbarradas at sapo.pt
ruipbarradas at sapo.pt
Thu Jul 7 13:59:15 CEST 2016
Hello,
Maybe something like the following (untested).
idx <- Matched %in% df2$Serial
MatchedCount <- df2$Count[idx]
Hope this helps,
Rui Barradas
Citando ch.elahe via R-help <r-help at r-project.org>:
> Hi all,
> I have 2 data frames like the following:
> the first one df1:
>
> 'data.frame': 141obs. of 1 variable:
> $SerialNum: int 41006 41013 41044 41046 41067 41166 41202 41262
> 41274 41290
> and the second one df2:
>
> 'data.frame': 194 obs. of 2 variables:
> $Serial: int 41006 41013 41018 41044 41046 41067 41111 41200 41262 41331
> $Count : int 1 10 103 11 12 13 138 14 15 16 169 18 182 2 20 21 224 226
> then I find the intersect of two data frames in serials which is:
>
> Matched=intersect(df1$SerialNum,df2$Serial)
> which gives me matched serials in both data frames. Next I want to
> get Count of these matched serials from df2 but I don't know how to
> make the right subset for this! Does anyone know how should I do that?
> Thanks for any help,
> Elahe
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.htmland provide commented,
> minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help
mailing list