'How to convert all NAs in a data set to blank values (regardless of class of vector)

I'd like to convert all the NAs in my very large data set to blank values ""

I believe the issue that I have is that some columns are string, some are numeric, etc.

The data set has >200 columns and millions of rows so it is pretty complicated for me.

The reason I'd like them all blank is because I want to merge columns together at some point, and I need the columns with NAs to just disappear during the merge.

When I try dataset[is.na(dataset)] <- ""

I get the following error:

ℹ Error occurred for column x.
x Can't convert < character> to < double>.

Does anybody have advice or suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source