I have a titanic xlsx file that has many empty or empty cells, and I saved the file as csv and all the spaces were saved as is.
When I import a csv file, I see a lot of empty lines / spaces in the data set, one of these columns is a boat
I could just go and use readxl package functions like read_xls or read_xlsx that would replace empty NA lines
But I would like to know if there is a way if I can replace the empty lines after loading in R in the dataframe.
I tried this way, but it causes an error that I don't understand exactly. I can specify NA in "NA" in the code below, then it will replace NA, but it will be a string (NA) not missing the NA value, both will be different.
titanic %>% mutate(boat = if_else(boat=="", NA ,boat))
Error in mutate_impl(.data, dots) :
Evaluation error: `false` must be type logical, not character.
source
share