[R] Subset by using multiple values
clangkamp
christian.langkamp at gmxpro.de
Mon Nov 29 20:27:47 CET 2010
Hi
I would like to extend this item to the following:
I have the following table
X1 X2 X3 value
1 BVEq AGR 11412 954.75
2 CA_Tot AGR 11412 970.59
...
> str(DC2_m)
'data.frame': 104160 obs. of 4 variables:
$ X1 : Factor w/ 62 levels "BVEq","CA_Tot",..: 1 2 3 4 5 6 45 46 47 48
...
..- attr(*, "names")= chr "Figure.1" "Figure.995" "Figure.17873"
"Figure.17874" ...
$ X2 : Factor w/ 48 levels "AGR","AKZ","ALB",..: 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "names")= chr "1" "1" "1" "1" ...
$ X3 : int 11412 11412 11412 11412 11412 11412 11412 11412 11412 11412
...
$ value: num 955 971 NA NA NA ...
And I have a second (manual) table with entries of combinations of X2 and X3
which I want to exclude:
> str(Exclude_Data)
'data.frame': 8 obs. of 2 variables:
$ Code : Factor w/ 5 levels "ALB","ALQ","BAY",..: 3 3 2 4 5 3 1 2
$ Dates: int 12052 12233 12508 11960 13056 12142 12691 12783
subset(DC2_m, cbind(X2,X3) %in% Exclude_Data[])
Now the trick is to precisely exclude just the combinations chosen, and not
all combinations of Exclude_Data[1] and Exclude_Data[2], which is what
happens when doing two statements "X2 in ED[1]" AND "X3 in ED[3]".
Any takers ? Thanks in advance
Christian
--
View this message in context: http://r.789695.n4.nabble.com/R-Subset-by-using-multiple-values-tp815278p3064226.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list