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 in Data Analytics by sagar
34 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 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 26, 2018 in Data Analytics by Bharani
• 4,560 points
352 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

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

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,560 points
137 views
0 votes
4 answers

How to remove NA values with dplyr::filter()

Can we create a alist as below ...READ MORE

answered Aug 5 in Data Analytics by anonymous
10,921 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 darklord
• 6,190 points
359 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 5 in Data Analytics by anonymous
3,887 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 darklord
• 6,190 points
107 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 in Data Analytics by anonymous
• 32,260 points
6,148 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,070 points
67 views
0 votes
1 answer

Using Cuda: Tensorflow error

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

answered Jun 13 in Data Analytics by Zulaikha
• 870 points
59 views