I am trying to learn R but some errors stop me.
why R return NA for all my functions? I import my data and changed them to the data frame but even I want to calculate the mean it returns NA.
Here is my data information and my problem.
str(df)
'data.frame': 30506 obs. of 84 variables: ...
summary(df$age)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
20.00 32.00 41.00 41.71 51.00 65.00 57
mean( df$SleepDuration[df$Gender == 1] )
[1] NA
mean(df$age)
[1] NA