I have a df with 25 columns, of which 18 are of type character but with a numeric value, and the "NULL" values are also character, therefore it is not recognized as NA. How could I change the "NULL" values to "0" or simply transform the columns to integer and that the "NULL" remain as NA?
If we imagine one
data.frame
like the following:You can apply
as.integer()
by column:Note, that the return is an array, but it's trivial to convert to a
data.frame
and particularly, note that values with decimals as4.5
they are truncated, any other value that can't be converted will be aNA