[R] Mean, median and other moments
Jim Lemon
jim at bitwrit.com.au
Wed Dec 23 12:54:02 CET 2009
On 12/23/2009 10:24 PM, Amelia Livington wrote:
> Hi!
>
> Suppose I have a dataset as follows
>
> pd = c(10,7,10,11,7,11,7,6,8,3,12,7,7,10,10)
>
> I wish to calculate the mean, standard deviation, median, skewness and kurtosis i.e. regular standard statistical measures.
>
> average = mean(pd)
> stdev = sd(pd)
> median = median(pd)
> skew = skewness(pd)
> kurt = kurtosis(pd)
>
> Q. No (1)
>
> How do I get these at a stretch using some R package? I came across moments and e1071 package, but I am not sure which one to use and how?
>
> Q. No. (2)
> Many times I came across the command
>
> set.seed(1234)
>
> What is the significance of this command. I understand this is related to random number generation. But what does it do?
>
>
Hi Amelia,
For 1)
library(prettyR)
library(timeDate)
describe(pd,
num.desc=c("mean","sd","median","kurtosis","skewness"))
although there are many other ways to do this.
for 2)
set.seed() starts the random number generator at a particular place,
allowing you to generate the same set of "random" numbers repeatedly.
This can be useful for things like examples for which the particular set
of numbers should be repeated when anyone runs the example.
Jim
More information about the R-help
mailing list