Reputation: 33
I have this list of ~270'000 elements with each element having a length of either 165 or 166. What I would like is to isolate into a separate dataset those elements with length of 165.
Upvotes: 0
Views: 1361
Reputation: 1
How to select 2 items combined list in the apriori function:
rules <- apriori(Groceries,parameter = list(support = 0.01, confidence = 0.01, minlen = 2, maxlen = 2))
summary(rules3)
Upvotes: 0
Reputation: 388862
Try using lengths
:
result <- data2[lengths(data2) == 165]
Few other options include :
result <- Filter(function(x) length(x) == 165, data2)
result <- purrr::keep(data2, ~length(.x) == 165)
result <- purrr::discard(data2, ~length(.x) != 165)
Upvotes: 2
Reputation: 11584
Does this work:
set.seed(1)
mylist <- list(sample(1:10, 165, T), sample(1:10, 166, T), sample(1:10, 165, T), sample(1:10, 166, T))
l1 <- mylist[sapply(mylist, function(x) length(x) == 165)]
l2 <- mylist[sapply(mylist, function(x) length(x) == 166)]
Upvotes: 0