Filter using dplyr

0 votes
How to filter rows based on values for an entire row? Is there a way to filter row based on condition for an entire row or any one of the column?
Aug 2, 2019 in Data Analytics by sagar
976 views

1 answer to this question.

0 votes
@Sagar, use filter followed by condition for each column. But this would not be the best method for a large data frame with more columns.  Another way is to use filter_all( ).

Ex: filter_all(mtcars, all_vars(. > 150))

filter_all function applies the same condition to all columns and returns rows that satisfy the condition.

To filter rows if particular columns pass the condition use filter_at( ). You can specify the column/s using starts_with,ends_with,contains, matches, etc

Ex: filter_at(mtcars, vars(starts_with("d")), any_vars((. %% 2) == 0))
answered Sep 10, 2019 by kiran

Related Questions In Data Analytics

0 votes
1 answer

Using "dplyr" to summarise multiple columns

You can use the "sumamrise_all()" function for ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,696 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,259 views
0 votes
1 answer

How to use dplyr functions such as filter() inside nested data frames with map()

You can use map() call as follows:  map(full, ...READ MORE

answered Apr 6, 2018 in Data Analytics by Sahiti
• 6,370 points
4,865 views
0 votes
1 answer

How to filter a data frame with dplyr and tidy evaluation in R?

Requires the use of map_df to run each model, ...READ MORE

answered May 17, 2018 in Data Analytics by DataKing99
• 8,250 points
1,986 views
0 votes
2 answers

How to use group by for multiple columns in dplyr, using string vector input in R?

data = data.frame(   zzz11def = sample(LETTERS[1:3], 100, replace=TRUE),   zbc123qws1 ...READ MORE

answered Aug 6, 2019 in Data Analytics by anonymous
14,230 views
0 votes
1 answer

How to group all columns exculding a single column?

You can either use group_by or group_by_at Using ...READ MORE

answered Apr 12, 2018 in Data Analytics by Sahiti
• 6,370 points
3,663 views
0 votes
2 answers

How to remove rows with missing values (NAs) in a data frame?

Hi, The below code returns rows without ...READ MORE

answered Aug 20, 2019 in Data Analytics by anonymous
• 33,030 points
14,906 views
0 votes
1 answer

How to limit output of a dataframe in R?

For randomly sampling a row/cell where a ...READ MORE

answered Apr 18, 2018 in Data Analytics by kappa3010
• 2,090 points
3,583 views
0 votes
1 answer

Using Cuda: Tensorflow error

This command will tell you which processes ...READ MORE

answered Jun 13, 2019 in Data Analytics by Zulaikha
• 910 points
716 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP