Introduction to R (see R-start.doc)
Be careful -- R is case sensitive.
Reading data (Creating a dataframe)
- mydata=read.csv(file=file.choose())
Commands for dataframes
- mydata #shows the entire data set
- head(mydata) #shows the first 6 rows
- tail(mydata) #shows the last 6 rows
- str(mydata) #shows the variable names and types
- names(mydata) #shows the variable names
- ls() #shows a list of objects that are available
Descriptive Statistics
- mean(x) #computes the mean of the variable x
- median(x) #computes the median of the variable x
- sd(x) #computes the standard deviation of the variable x
- IQR(x) #computer the IQR of the variable x
- summary(x) #computes the 5-number summary and the mean of the variable x
- cor(x,y) #computes the correlation coefficient
Graphical Displays
- hist(x) #creates a histogram for the variable x
- boxplot(x) # creates a boxplot for the variable x
- boxplot(y~x) # creates side-by-side boxplots
- stem(x) #creates a stem plot for the variable x
- plot(y~x) #creates a scatterplot of y versus x
- abline(lm(y~x)) #adds regression line to plot
- lines(lowess(x,y)) # adds lowess line (x,y) to plot
Probability Distributions
- dbinom(x, n, p) #binomial density, probability
- pbinom(x, n, p) #cumulative binomial probability
- pnorm(x, mean, sd) #cumulative probability for a Normal distribution
- psignrank(x, n) #cumulative probability for Wilcoxon signed rank statistic with sample size = n
- pwilcox(x, n, m) #cumulative probability for Wilcoxon rank sum statistic with sample sizes n and m
Nonparametric Tests
- binom.test(x, n, p) #Binomial test for proportions
- binom.confint(x, n) #NEED binom package, confidence intervals for a proportion
- SIGN.test(x, md=0) #NEED BSDA package, Sign test
- wilcox.test(x) #Wilcoxon signed rank test
- owa(pre, post) #NEED NSM3 package, Ordered Walsh Averages
- HollBivSym(x,y) #Hollander's test for bivariate symmetry
- wilcox.test(x, y) #Wilcoxon rank sum test
- wilcox_test(x, y) # NEED coin package - Exact conditional distribution
- waerden.test(response, treatement) #NEED agricolae package, van der Waerden's Test
- pFligPoli(x, y, method="Monte Carlo") #NEED NSM3 package; approximate p-value for Fligner-Policello test)
- pFligPoli(x, y, method="Asymptotic") #NEED NSM3 package; LSA for Fligner-Policello test)
- ansari.test(x, y) #Ansari-Bradley test
- cAnsBrad(alpha, m, n) #NEED NSM3 package; provides critical value
- pAnsBrad(x, y) #NEED NSM3 package; provides p-value for Ansari-Bradley test
- MillerJack(x, y) #NEED NSM3 package; provides Miller Jackknife Q
- pLepage(x, y) #NEED NSM3 package; provides Lepage's test
- fligner.test(x, g) #Fligner-Killeen test of equal variances; g is a grouping variable
- ks.test(x,y) #Kolmogorov-Smirnov test
- kruskal.test(x, g) #Kruskal-Wallis rank sum test; g is a grouping variable
- cKW(alpha, n) #NEED NSM3 package; provides critical value for Kruskal-Wallis statistic
- pKW(x, g) #NEED NSM3 package; provides Kruskal-Wallis rank sum test; g is a grouping variable
- kruskalmc(response, group) #Need pgirmess package; g is a grouping variable
- cSDCFlig(alpha, n) #NEED NSM3 package; provides critical value for Dwass, Steel, Critchlow, Fligner statistic
- JT.test(data, g) #Need SAGx package; Jonckheere-Terpstra test; data is a matrix; g is a grouping variable
- pJCK(x, g) #NEED NSM3 package; provides Jonckheere-Terpstra test; g is a grouping variable
- cHaySton(alpha, n) #NEED NSM3 package; provides critical value for ordered alternatives multiple comparisons
- pHaySton(x, g) #NEED NSM3 package; provides ordered alternatives multiple comparisons; g is a grouping variable
- cNDWol(alpha, n)#NEED NSM3 package; provides critical value for treatment versus control multiple comparisons
- cMaxCorrNor(alpha, n)#NEED NSM3 package; provides LSA critical value for treatment versus control multiple comparisons
- cUmbrPK(alpha, n, p) #NEED NSM3 package; provides critical value for Mack-Wolfe Umbrella peak known statistic
- pUmbrPK(x, peak, g) #NEED NSM3 package; provides Mack-Wolfe Umbrella peak known test; g is a grouping variable
- cUmbrPU(alpha, n, p) #NEED NSM3 package; provides critical value for Mack-Wolfe Umbrella peak unknown statistic
- pUmbrPU(x, g) #NEED NSM3 package; provides Mack-Wolfe Umbrella peak uknown test; g is a grouping variable
- friedman.test(y~A|B)
# y are the data values, A is a grouping factor, and B is a blocking factor
- cPage(alpha, k, n) #NEED NSM3 package; provides critical value for Page's test, k is number of treatments, n is number of blocks
- pPage(x, b, trt) #NEED NSM3 package; provides Page's test for ordered alternatives; b identifies blocks, trt identifies treatments
- cWNMT(alpha, k, n) #NEED NSM3 pacakge; provides critical value for two-sided follow-up muliple comparisons for a RCBD; k is number of treatments, n is number of blocks
- pWNMT(x, b, trt) #NEED NSM3 pacakge; provides two-sided follow-up muliple comparisons for a RCBD; b identifies blocks, trt identifies treatments
- cNWWM(alpha, k, n) #NEED NSM3 pacakge; provides critical value for one-sided treatment versus control muliple comparisons for a RCBD; k is number of treatments, n is number of blocks
- pNWWM(x, b, trt) #NEED NSM3 pacakge; provides one-sided treatment versus control muliple comparisons for a RCBD; b identifies blocks, trt identifies treatments
- cor.test(x,y) #correlation test plus CI for several measures of association (r, rho, tau)
- kendall.ci(x, y) #NEED NSM3 package; provides a confidence interval for Kendall's tau