Mean and SD in R -
maybe easy question. data.frame:
> read.table("text.txt") v1 v2 1 26 22516 2 28 17129 3 30 38470 4 32 12920 5 34 30835 6 36 36244 7 38 24482 8 40 67482 9 42 23121 10 44 51643 11 46 61064 12 48 37678 13 50 98817 14 52 31741 15 54 74672 16 56 85648 17 58 53813 18 60 135534 19 62 46621 20 64 89266 21 66 99818 22 68 60071 23 70 168558 24 72 67059 25 74 194730 26 76 278473 27 78 217860
it means have 22516 sequences length 26, 17129 sequences length 28, etc. know sequence length mean , standard deviation. know how it, know creating list full of 26 repeated 22516 times , on... , compute mean , sd. however, thing there easier method. idea?
thanks.
for mean: (v1 %*% v2)/sum(v2)
for sd: sqrt(((v1-(v1 %*% v2)/sum(v2))**2 %*% v2)/sum(v2))
Comments
Post a Comment