Reputation: 1572
I'm struggling with this simple task
I have a list of vectors and I want to extract values in a range, lets say between 1700 and 6200.
sample <- list(c(1062, 1084, 1104, 1130, 1143, 1178, 1193, 1209, 1233,
1276, 1315, 1458, 1752, 2027, 2483, 2598, 2713, 3196, 3780, 4448,
4937, 5070, 5734, 6347, 6859, 6963), c(1101, 1125, 1153, 1166,
1201, 1214, 1257, 1281, 1315, 1351, 1493, 1786, 2061, 2514, 2559,
2583, 2628, 2742, 3185, 3223, 3801, 4469, 4954, 5090, 5753, 6364,
6874, 6978))
sapply(sample, function(x) x[x > 1700])
sapply(sample, function(x) x[x < 6200])
How to combine theses two functions in one ?
sapply(sample, function(x) x[x > 1700] & x[x<6200])
doesn't work, why ? What am I missing ?
Upvotes: 1
Views: 4197