[R] Mean, median and other moments

John Sorkin jsorkin at grecc.umaryland.edu
Wed Dec 23 13:16:01 CET 2009


An answer to your second question:
Random number generated by your computer are not truly random, they are pseduo random meaning that if your computer is it the exact same state at two movements, it will produce the same string of "random" numbers. Set.seed effectively puts your machine in a given state - it primes the pseudo random number generator. If you set the seed before requesting a set of random numbers, you will always get the same set of numbers. If you don't use set.seed, the machine primes the generator using some other source, which may be the system clock. Thus, if you don't use set.seed, it would be very, very, unlikely that you would get the same string of random numbers.
John




John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)>>> Amelia Livington <amelia_livington at yahoo.com> 12/23/2009 6:24 AM >>>
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?

Thanking in advance

Amelia



      
	[[alternative HTML version deleted]]


Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}




More information about the R-help mailing list