Learn how to use arithmetic and logical operators in R. These binary operators work on vectors, matrices, and scalars.
Learn in R how about creating, recoding, and renaming variables programitically or interactively.
Subsetting Data . R has powerful indexing features for accessing object elements. These features can be used to select and exclude variables and observations.
Learn how to create a scatterplot in R. The basic function is plot(x, y), where x and y are numeric vectors denoting the (x,y) points to plot.
Learn how to use the cor() function in R and learn how to measure Pearson, Spearman, Kendall, Polyserial, Polychoric correlations.
About Quick-R. R is an elegant and comprehensive statistical and graphical programming language. Unfortunately, it can also have a steep learning curve.I created this website for both current R users, and experienced users of other statistical packages (e.g., SAS, SPSS, Stata) who would like to transition to R.
Graphic User Interfaces . R is a command line driven program. The user enters commands at the prompt ( > by default ) and each command is executed one at a time. There have been a number of attempts to create a more graphical interface, ranging from code editors that interact with R, to full-blown GUIs that present the user with menus and dialog boxes.
t-tests. The t.test( ) function produces a variety of t-tests. Unlike most statistical packages, the default assumes unequal variance and applies the Welsh df modification.# independent 2-group t-test t.test(y~x) # where y is numeric and x is a binary factor
Combining Plots . R makes it easy to combine multiple plots into one overall graph, using either the par( ) or layout( ) function. With the par( ) function, you can include the option mfrow=c(nrows, ncols) to create a matrix of nrows x ncols plots that are filled in by row.mfcol=c(nrows, ncols) fills in the matrix by columns.# 4 figures arranged in 2 rows and 2 columns
Cluster Analysis . R has an amazing variety of functions for cluster analysis.In this section, I will describe three of the many approaches: hierarchical agglomerative, partitioning, and model based.
Boxplots . Boxplots can be created for individual variables or for variables by group. The format is boxplot(x, data=), where x is a formula and data= denotes the data frame providing the data. An example of a formula is y~group where a separate boxplot for numeric variable y is generated for each value of group.Add varwidth=TRUE to make boxplot widths proportional to the square root of the ...
Graphical Parameters. You can customize many features of your graphs (fonts, colors, axes, titles) through graphic options. One way is to specify these options in through the par( ) function.If you set parameter values here, the changes will be in effect for the rest of the session or until you change them again.
Descriptive Statistics . R provides a wide range of functions for obtaining summary statistics. One method of obtaining descriptive statistics is to use the sapply( ) function with a specified summary statistic. # get means for variables in data frame mydata
Graphics with ggplot2. The ggplot2 package, created by Hadley Wickham, offers a powerful graphics language for creating elegant and complex plots. Its popularity in the R community has exploded in recent years. Origianlly based on Leland Wilkinson's The Grammar of Graphics, ggplot2 allows you to create graphs that represent both univariate and multivariate numerical and categorical data in a ...
If you are going to create a custom axis, you should suppress the axis automatically generated by your high level plotting function. The option axes=FALSE suppresses both x and y axes.xaxt="n" and yaxt="n" suppress the x and y axis respectively. Here is a (somewhat overblown) example.
Bootstrapping Nonparametric Bootstrapping . The boot package provides extensive facilities for bootstrapping and related resampling methods. You can bootstrap a single statistic (e.g. a median), or a vector (e.g., regression weights). This section will get you started with basic nonparametric bootstrapping.
Exporting Data . There are numerous methods for exporting R objects into other formats . For SPSS, SAS and Stata, you will need to load the foreign packages. For Excel, you will need the xlsReadWrite package.. To A Tab Delimited Text File
Aggregating Data . It is relatively easy to collapse data in R using one or more BY variables and a defined function. # aggregate data frame mtcars by cyl and vs, returning means
Importing Data . Importing data into R is fairly simple. For Stata and Systat, use the foreign package. For SPSS and SAS I would recommend the Hmisc package for ease and functionality. See the Quick-R section on packages, for information on obtaining and installing the these packages.Example of importing data are provided below.
Discriminant Function Analysis . The MASS package contains functions for performing linear and quadratic discriminant function analysis. Unless prior probabilities are specified, each assumes proportional prior probabilities (i.e., prior probabilities are based on sample sizes).
Learn how to create, save, and view graphs in R. You can have multiple graph windows open at one time. See help(dev.cur) for more details.. Alternatively, after opening the first graph window, choose History -> Recording from the graph window menu.Then you can use Previous and Next to step through the graphs you have created.. Graphical Parameters
The Workspace . The workspace is your current R working environment and includes any user-defined objects (vectors, matrices, data frames, lists, functions).
R Tutorial Obtaining R. R is available for Linux, MacOS, and Windows. Software can be downloaded from The Comprehensive R Archive Network (CRAN).. Startup. After R is downloaded and installed, simply find and launch R from your Applications folder.
Nonparametric Tests of Group Differences . R provides functions for carrying out Mann-Whitney U, Wilcoxon Signed Rank, Kruskal Wallis, and Friedman tests.
Value Labels . To understand value labels in R, you need to understand the data structure factor.. You can use the factor function to create your own value labels.
For example, pnorm(0) =0.5 (the area under the standard normal curve to the left of zero).qnorm(0.9) = 1.28 (1.28 is the 90th percentile of the standard normal distribution).rnorm(100) generates 100 random deviates from a standard normal distribution. Each function has parameters specific to that distribution. For example, rnorm(100, m=50, sd=10) generates 100 random deviates from a normal ...
Time Series and Forecasting. R has extensive facilities for analyzing time series data. This section describes the creation of a time series, seasonal decomposition, modeling with exponential and ARIMA models, and forecasting with the forecast package.. Creating a time series
Sorting Data . To sort a data frame in R, use the order( ) function.By default, sorting is ASCENDING. Prepend the sorting variable by a minus sign to indicate DESCENDING order.
Pie Charts . Pie charts are not recommended in the R documentation, and their features are somewhat limited. The authors recommend bar or dot plots over pie charts because people are able to judge length more accurately than volume. Pie charts are created with the function pie(x, labels=) where x is a non-negative numeric vector indicating the area of each slice and labels= notes a character ...