filter many times a tibble

BillyPocheo

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 ?

thefringthing

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

After using If statement in Custom filter the page being redirected many times

From Dev

Filter a tibble with two conditions

From Dev

Filter tibble by group

From Dev

Filter a tibble in mutate based on another tibble?

From Dev

How to filter a tibble and turn it into a matrix?

From Dev

How to graph a times series tibble by decade

From Dev

Filter array based on an object's property value relative to how many times it occurs in other elements

From Dev

Why does filter(_:)’s predicate get called so many times when evaluating it lazily?

From Dev

How to filter strings by a limit of how many times each character can occur?

From Dev

How to filter an array of objects and order them based on how many times they show up in array

From Dev

How to filter a dataframe multiple times in a loop with Pandas (multiple conditions and one-to-many dataframe results)

From Dev

Django many to many filter

From Dev

Rails - filter many to many

From Dev

Slider slides many times

From Dev

Regex to match many times

From Java

using @Autowired many times

From Dev

How to not repeat == many times

From Dev

Undo many times in Vim?

From Dev

SetState called many times

From Dev

How to filter dataframes based on criteria in a tibble?

From Dev

Filter once or filter multiple times

From Dev

Filter applying muliple times

From Python

Django filter for many to many by multiple

From Python

Django filter for many to many by multiple

From Dev

Django: Filter many to many field

From Dev

Django Many To Many field with filter

From Dev

backward filter and many to many relationship

From Dev

Django query filter many to many to many etc

From Dev

onLayoutChange() called too many times

Related Related

HotTag

Archive