0 votes
in SoSci Survey (English) by s165375 (120 points)

Within my data frame, there are quite many "na" values as some values (for experimental reasons) are not collected from all groups. When I try to replace this "na" values with 0, the following error code comes, although I did import the R code with the GNU R script provided by SoSci Survey.

My Code:
dataframeMA[is.na(dataframeMA)] <- 0

The Error:
Fehler in as.POSIXct.numeric(value) : 'origin' must be supplied

I can't find the reason for this code or how to resolve it.

Thank you!

1 Answer

0 votes
by SoSci Survey (330k points)

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.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...