Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

How to remove specific rows when a condition is fulfilled?

$
0
0

I am trying to remove/filter out some specific rows when it meets the condition of the two columns if not the column EP is flagged as 1. What is the specific code for this? For example: in the dataframe df_NC when the column "Population_type" (binary type) is equal to 1 and the column NC (binary type) is equal to 0 remove the rows when this condition is satisfied, else flag EP as 1

df_ep <- df_NC %>% mutate(EP= case_when(
 df_NC$Population_Type == 1 & df_NC$NC == 0 ~ 1,
 TRUE ~ 0
))

Viewing all articles
Browse latest Browse all 201894

Trending Articles