Https://www.codecademy.com/courses/learn-r/projects/variance-in-weather-r

Hi everyone,

I found a similar threat which didn’t answer my question. I am working with temperature data from London and need to calculate the average temperature and the variance.

I am able to calculate and print the average/mean, but the variance function is not working. I checked my spelling 3 times and cannot find the error. It seems to me, the variance function is not properly loaded or something like that. Someone has an idea?

  • See slide 25 and 26 on the screenshot, and the error message in the notebook ```
    Error in variance(temp): could not find function “variance”


![Schermafbeelding 2020-05-25 om 14.43.24|690x326](upload://5oYTsYGdg8uDue9hunscJ5RzbQM.png)

Seems the screenshot is not working…

Use var instead of variance – that’s a typo in the hint.

1 Like

Thank you! It works now

Hi, I’m working through this one myself, for which thanks for providing this answer. Why is this the solution though, the prior lessons leading up to this project had us using variance rather than var?

Perhaps because they had us define it in an earlier lesson like so would understand what variance is.

variance <- function(x) mean((x-mean(x))^2)