I have the following dataset:
dat2 <- read.table(header=TRUE, text="
ID De Ep Ti ID1
A1123 A117 121 100 11231
A1123MDN A108 C207 D110 E11232
A1124MDN A122 C207 D110 E11232
A1124MDN A117 C207 D110 E11232
A1124 A122 C208 D110 E11232
B1125MDN A108 C208 D110 E11232
B1125MDN A108 C208 D110 E11232
B1126MDN A122 C208 D110 E11233
C1126 A109 C208 D111 E11233
")
dat2
ID De Ep Ti ID1
1 A1123 A117 121 100 11231
2 A1123MDN A108 C207 D110 E11232
3 A1124MDN A122 C207 D110 E11232
4 A1124MDN A117 C207 D110 E11232
5 A1124 A122 C208 D110 E11232
6 B1125MDN A108 C208 D110 E11232
7 B1125MDN A108 C208 D110 E11232
8 B1126MDN A122 C208 D110 E11233
9 C1126 A109 C208 D111 E11233
I want to subset the dataset based on part of a sting MDN
in first columns. The lengthy code is:
mdn <- subset(dat2, ID=="A1123MDN"|ID=="A1124MDN"| ID=="B1125MDN"| ID=="B1126MDN")
mdn
ID De Ep Ti ID1
2 A1123MDN A108 C207 D110 E11232
3 A1124MDN A122 C207 D110 E11232
4 A1124MDN A117 C207 D110 E11232
6 B1125MDN A108 C208 D110 E11232
7 B1125MDN A108 C208 D110 E11232
8 B1126MDN A122 C208 D110 E11233
The data set has 456,345 rows. It is not feasible to subset by following the above way.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…