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
169 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 26, 2018 in Data Analytics by Bharani
• 4,580 points
863 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,580 points
262 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, 2019 in Data Analytics by anonymous
58,812 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,320 points
1,352 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, 2019 in Data Analytics by anonymous
7,696 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,320 points
1,115 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
• 32,490 points
11,415 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
159 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
139 views