I'm working through the exercises at the end of each chapter of McNulty's Handbook of Regression Modeling in People Analytics. I'm currently stuck on problem number nine from the end of the chapter two, which reads:
Using the pipe operator, write code to find the mean of the Yr1 test scores for all those who achieved Yr3 test scores greater than 100. Round this mean to the nearest integer.
I've attempted several different approaches and scoured Stack Overflow for new strategies but am coming up short.
filter(ugtests, Yr3 > 100)%>%
colMeans(ugtests[1], na.rm = TRUE) %>%
round(digits = 0) #Error in colMeans(., ugtests[1], na.rm = TRUE) : invalid 'dims'
filter(ugtests, Yr3 > 100)%>%
mean(ugtests$Yr1) %>%
round(digits = 0) #Warning message:In mean.default(., ugtests$Yr1) : argument is not numeric or `logical: returning NA
filter(ugtests, Yr3 > 100)%>%
mean() %>%
round(digits = 0)#Warning message: In mean.default(.) : argument is not numeric or logical: returning NA