I have a vector of data and I want to 'manually' calculate variance and standard deviation.
pointsPerGame<-c(28,26,10,27,20,38,23,28,25,2)
I can get the deviation scores like this
pointsPerGame - mean(pointsPerGame)
But when I try to get the sum of the deviation scores it won't sum to zero like it should.
deviationScores<- pointsPerGame - mean(pointsPerGame)
sum(deviationScores)
I know this has to do with the level of precision in R, but I don't know how to prevent it from doing so for my purposes.
Hope you can help.
This question has been flagged as an answer to my question Why are these numbers not equal? But I want R to display 0 for teaching purposes, it'd be extremely confusing to get into the details of floating points etc.