filter and remove rows in dataframe

Hello.
I have dataframe(data) with many columns and rows. Some rows contain cells with specific text(text is "FALSE").How can i filter rows with this text and then remove these rows.

It would be better if you can give a sample data.
When you filter a variable and make a new data frame, automatically the observations you have given will be removed. Here is a sample I have made below.

library(tidyverse)
library(janitor)


data<-tibble::tribble(
  ~variable,
       TRUE,
       TRUE,
       TRUE,
       TRUE,
       TRUE,
       TRUE,
      FALSE,
      FALSE,
      FALSE,
      FALSE,
      FALSE,
      FALSE
  )

data_mod<-data %>% 
  filter(variable=="TRUE")

Hope this helps,
NP

Thanks for your replay.

My data is like this: 

   A    B     C           D 
1. 0     4    4           false 
2. 5     4    4           0 
3. 5     4    false       4 
4. 5     0    4           4 
5. 0     4    4           4 
6. 5     4    4           4 
7. 0     4    4           false 

i want to find all rows that contain "false" or "0", remove this rows from existing data and make another dataframe with these removed rows.

For the sample, the following code, the below code will work. If you have a lot of variables will have to try across function.

library(tidyverse)
library(janitor)

data<-tibble::tribble(
  ~A, ~B,      ~C,      ~D,
  0L, 4L,     "4", "FALSE",
  5L, 4L,     "4",     "0",
  5L, 4L, "FALSE",     "4",
  5L, 0L,     "4",     "4",
  0L, 4L,     "4",     "4",
  5L, 4L,     "4",     "4",
  0L, 4L,     "4", "FALSE"
  )

data_mod<-data %>% 
  filter(!C=="FALSE") %>%   
  filter(!(D=="FALSE" | D=="0"))
1 Like

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.