How Can I Calculate Standard Deviation (step-by-step) in R?

  • How can I calculate Standard Deviation, step-by-step, in R? Thanks!

    Do you know the formula for standard deviation? Can you elaborate on 'step by step'?

    Hi! Yes, I believe do! I'm trying to calculate sd for a specific data set. I am aware that I can simply use the sd function, but I need to calculate the standard deviation of a data set "by hand," using R. These are the values: [1] 179 160 136 227 217 168 108 124 143 140 309 229 181 141 260 203 148 169 213 257 244 [22] 271 243 230 248 327 329 250 193 271 316 267 199 171 158 248 423 340 392 339 341 226 [43] 320 295 334 322 297 318 325 257 303 315 380 153 263 242 206 344 258 368 390 379 260 [64] 404 318 352 359 216 222 283 332 Thank you!

    $variance = \frac{sum((x-mean(x))^2)}{(length(x)-1)}$

  • rightskewed

    rightskewed Correct answer

    5 years ago
    > a <- c(179,160,136,227)
    > sd(a)
    [1] 38.57892
    > sqrt(sum((a-mean(a))^2/(length(a)-1)))
    [1] 38.57892
    

    ```

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM