Looks like dataframeMA
is not a numeric variable, but your whole data.frame
including a date (POSIXct
) that cannot simply be set to 0.
I recommend being very careful with simply replacing NA
by 0
, and limit that to single variables:
dataframeMA$AB01[is.na(dataframeMA$AB01)] = 0
Of course you can use a loop to do that for several variables at once.
Actually, I recommend using tidyverse
for such operations, for example replace_na().
Watch out: If you replace the wrong variables, you will screw up the whole dataset and all means and correlations.