I have a problem under R with dplyr I have a tibble with 3 colomns (id, number of people, number of graduated) I would like to do this
tibble = filter (number of people == 2000 & number of graduated < 2) %>%
filter (number of people == 3000 & number of graduated < 3) %>%
filter (number of people == 4000 & number of graduated < 4) ...
and to this till I go to the max len of my colomn
Then i'll do a bindrows in order to create a tibble with these rows
But how can I proceed ?
Chaining filters like this means you're taking a subset of a subset of a subset, etc. But this will be empty right away, since a row can't have number_of_people == 2000 and == 3000, right? Maybe you mean "or" instead of "and"? It tough to infer what you're trying to do without seeing your data, since your question doesn't really make sense.
Here's my best guess:
# create some dummy data
data <- data.frame(
number_of_people = 1000 * sample(1:10, 100, replace = TRUE),
number_graduated = sample(1:10, 100, replace = TRUE)
)
# keep rows where graduates < people/1000
data <- data[data$number_graduated < data$number_of_people/1000, ]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments