I'm trying to calculate to median of a integer, but it keeps returning zero.
So I first use the pipeline and filter some rows in my dataset. In the pr variable there are 288 numbers stored.
pr <- data_raw %>%
filter(date == "2012-10-06") %>%
pull(steps)
pr
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[38] 0 0 0 0 0 40 11 0 0 0 0 0 0 0 0 0 19 67 0 0 0 0 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0
[75] 0 36 50 38 0 4 42 14 8 135 172 124 31 52 0 104 170 58 0 0 75 0 0 211 321 149 0 82 94 225 216 199 50 187 30 0 65
[112] 173 43 0 0 0 0 0 0 0 16 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 95 64 7 33 72 221 439 519 440
[149] 394 97 71 10 87 443 500 465 485 351 515 511 506 486 171 12 24 42 140 15 0 43 67 48 0 0 9 31 30 64 115 25 0 27 0 0 0
[186] 0 0 0 0 0 0 0 27 27 0 0 9 0 0 54 35 0 49 0 0 0 0 93 0 0 13 0 6 12 0 0 34 77 173 370 402 504
[223] 485 437 526 264 0 35 124 93 0 0 0 0 0 0 0 0 0 0 0 0 33 118 0 6 0 262 33 46 35 0 0 0 0 0 0 0 0
[260] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
I calculated the mean of pr which seems ok. But the median keeps returning zero.
length(pr)
[1] 288
class(pr)
[1] "integer"
mean(pr)
[1] 53.54167
median(pr)
[1] 0
Does someone know why is this happening?
Thank you