In my dataset, I have this variable called Freq that has values for the individuals that had a recording and is NA for the rest. I want to turn these NAs to zeros, as it serves the purpose of my analysis.
I tried:
poisson_data3 <- poisson_data2 %>% mutate(Freq2 = case_when(is.na(Freq)~ 0,
!is.na(Freq)~ Freq))
where i create a new variable called Freq2 which uses the values from Freq (when they are there) and is 0 (when there are no values).
However this returns an error in R.
Any suggestions on how this could be solved or if any other command would be better?
Thanks in advance