What's the best formula to delete rows where an row has NA value?
will this work?
all_trips_v2 <- all_trips_v2 %>%
filter(!(ride_length = "NA"))
Want to delete all rows where ride_length = NA
What's the best formula to delete rows where an row has NA value?
will this work?
all_trips_v2 <- all_trips_v2 %>%
filter(!(ride_length = "NA"))
Want to delete all rows where ride_length = NA
In your example, the filter
should be...
new_df <- all_trips_v2 %>%
filter(!is.na(ride_length))
EDIT: A filter
doesn't necessarily 'delete' rows. Also, "NA" in quotes, a character string, is not the same as an NA as in...no value.
You should remove the paranthesis around "NA", otherwise you will match the character pattern "NA" not actual NAs. You may look at the functions na.omit(), complete.cases() or is.na() - so something like filter(!is.na(ridge_length))