##### R tips ##### updated on 01/19/2011 ### R tips No. 1: how to use R helps? # want to know how to use function "runif" ?runif # want to know how to generate random numbers from normal distribution help.search("normal distribution") ?Normal ### R tips No. 2: how to print or save R graphs? # if use menu operations: [1] click the R graph window; # [2] (menu)File --> print or File --> Save as # if use R command lines: for example, to save the graph into a file "normal.ps" x <- rnorm(1000, mean=1, sd=2) postscript("normal.ps",paper="special",width=8,height=7,horizontal=F) par(mfrow=c(1,1)) hist(x, freq=F) curve(dnorm(x, mean=1, sd=2), lwd=2, lty=2, add=T) dev.off() ## R tips No. 3: how to count the computation time (in seconds) tempt <- proc.time() temp <- runif(10000000) proc.time()-tempt ## R tips No. 4: generating random numbers from distributions of standard parameter families ## available R functions # rbeta -- The Beta Distribution # rbinom -- The Binomial Distribution # rcauchy -- The Cauchy Distribution # rchisq -- The (non-central) Chi-Squared Distribution # rexp -- The Exponential Distribution # rf -- The F Distribution # rgamma -- The Gamma Distribution # rgeom -- The Geometric Distribution # rhyper -- The Hypergeometric Distribution # rlnorm -- The Log Normal Distribution # rlogis -- The Logistic Distribution # rmultinom -- The Multinomial Distribution # rnbinom -- The Negative Binomial Distribution # rnorm -- The Normal Distribution # rpois -- The Poisson Distribution # rsignrank -- Distribution of the Wilcoxon Signed Rank Statistic # rt -- The Student t Distribution # runif -- The Uniform Distribution # rweibull -- The Weibull Distribution # rwilcox -- Distribution of the Wilcoxon Rank Sum Statistic