0
votes

I have a question relative to R dplyr filter function. I have a tibble data1 with several columns, and I would like to remove all rows where the the column "CODE_FRAIS" is filled with the code "CINT". My code to do so is :

data1 <- data1 %>% filter(CODE_FRAIS != "CINT")

But doing so, the filtered table returns only 0 for all numeric columns. And I don't understand why. And it's driving me crazy. Especially because this methodology usually works fine. Does anyone has an idea of what is going on here (and please, other than those involving my intellect ^^) Thank you very much in advance !

1
can you please provide sample data? - nurandi
Did you try: data1 %>% dplyr::filter(CODE_FRAIS != "CINT") , because there are likely to be several filter functions present in r additional to the dplyr one. - user12256545
I just tried it, it does not change the result... - Alpha Blue

1 Answers

-1
votes

Assuming you want to replace the rows with 0. You can't have unbalanced tables, you can either replace these values or equate them with NA and then use !is.na to filter out.

data1$CODE_FRAIS=ifelse(data1$CODE_FRAIS=="CINT",0,data1$CODE_FRAIS)