Im very new to R but i find it very interesting to learn .
So i searched a lot and although there were a lot of posts addressing the issue of counting missing values in multiple columns using
na_count <-sapply(data, function(y) sum(length(which(is.na(y)))))
na_count <- data.frame(na_count)
but could not find a specific answer for my issue.
I have a dataset in which there is a column called species and another column called weight in which there are some missing values .
I need to find the missing values in 'weight'grouped by species . I need to use group_by and summarize.
One of the errors that Im getting is
Factor species
contains implicit NA, consider using forcats::fct_explicit_na
I think this is related to the fact that the column im grouping by '(species) also has NA.
I have tried
DF %>%
group_by(species) %>%
summarize(funs(sum(is.na(weight))))
This doesnt work though.
Finally i need to impute the mean weight for each species in the missing values.
Cheers