fary
1
hello everybody.
I know it is a stupid question but I can't find where is the mistake.
i am running these lines of code
df%>%
select(BMI, Gender)%>%
filter(Gender== "Male" |
Gender == "Female")%>%
group_by(Gender)%>%
summarise(average_BMI = mean(BMI))
but I get this result:
average_BMI
1 NaN
FJCC
2
The NaN result will happen if one of your BMI values is NaN. Try running this code
NewDF <- df%>%
select(BMI, Gender)%>%
filter(Gender== "Male" | Gender == "Female")
and then run summary(NewDF)
. Does the summary of the BMI column say it has any NA's? If so, add na.rm = TRUE to your calculations of the mean.
mean(BMI, na.rm = TRUE)
system
Closed
3
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.