**Installing R, RStudio, and R Commander:**

Variable Types, and Graphical and Numerical Summary

Variable Types, and Graphical and Numerical Summary

Navigate a browser to http://cran.r-project.org

R Commander leverages the power of R for statistical computing and graphics in a GUI.

install.packages(c("Rcmdr","XLConnect","RcmdrPlugin.HH"), dependencies=TRUE)

library(Rcmdr)

R works.

**Either**

**Way**

R Commander's Input Window

R Script

A script, in plain text, representing commands issued through the R Commander Graphical User Interface.

Commands can also be issued using “Submit” on highlighted syntax.

R Markdown

A scripting language for representing commands issued through the R Commander Graphical User Interface and user interpretation that embeds graphical output in the .html output.

``Generate HTML report’’ processes the embedded R computations and text comments from the Markdown to an .html output document.

R Commander's Output Window

The output of computations performed by R submitted through interaction with the menu system or “Submit” on highlighted syntax.

What are R Commander’s Two Tabs?

R is a ``statistical package'' in name only.

R is a programming language for data.

R works like math (at least to me).

Functions on objects create new objects

( <- is the assignment operator).

R has broad data storage capabilities.

R has internal support for lists and arrays.

R interacts with SQL and many databases and numerous APIs including Twitter and Yahoo! Finance.

R stores variables as data should be stored.

Quantitative: Numeric variables are numeric.

Qualitative: Factors can be, at most, ordered.

R is extensible.

Packages have a search engine: rseek.org

R produces beautiful graphics quickly and easily.

R is not “statistical software”

The script window:

can be used to enter R syntax

records the commands generate by interaction with the GUI

The R Script window is an editor for the terminal with the convenience of command storage.

``Generate HTML report’’ processes the embedded R computations and text comments from the Markdown to an .html output document.

R Markdown

The box is out of line to make it fit on the page.

We combine interpretive text and analysis using the GUI; the markdown logs our results, graphics, and computations in the order that we undertake them.

Statistics > Summaries > Numerical Summaries

Only the numeric variables are available.

Statistics > Summaries > Active data set

Discrete

Numeric

Only the qualitative variables are available.

Statistics > Summaries > Frequency Distributions

R goes in between ```

and is placed there automatically by the R Commander as we issue clicks.

Interpretive text goes outside the R code.

There is considerable available formatting as well.

Graphics open in their own window

An output object is a function applied to an input object.

The function is named samp.med and it draws 100000 samples from the input data object and calculates the median for each sample.

Output object

Function

Input object

In this case, R will record 100,000 medians based on random samples of size 184 from 5 Year Returns.

Plot a histogram of my 100,000 medians.

Reference: Median5YR.R

R Commander's Input Window

R Script

A script, in plain text, representing commands issued through the R Commander Graphical User Interface.

Commands can also be issued using “Submit” on highlighted syntax.

R Markdown

A scripting language for representing commands issued through the R Commander Graphical User Interface and user interpretation that embeds graphical output in the .html output.

``Generate HTML report’’ processes the embedded R computations and text comments from the Markdown to an .html output document.

R Commander's Output Window

The output of computations performed by R submitted through interaction with the menu system or “Submit” on highlighted syntax.

What are R Commander’s Two Tabs?

The script window:

can be used to enter R syntax

records the commands generate by interaction with the GUI

The R Script window is an editor for the terminal with the convenience of command storage.

``Generate HTML report’’ processes the embedded R computations and text comments from the Markdown to an .html output document.

R Markdown

The box is out of line to make it fit on the page.

We combine interpretive text and analysis using the GUI; the markdown logs our results, graphics, and computations in the order that we undertake them.

R goes in between ```

and is placed there automatically by the R Commander as we issue clicks.

Interpretive text goes outside the R code.

There is considerable available formatting as well.

Density plot:

5 Year Returns by Type

Histogram

Boxplot [called box-and-whisker]

Density Plot: 5 Year Returns

Density plot:

5 Year Returns by Type

Histogram

Boxplot [called box-and-whisker]

Density Plot: 5 Year Returns

Our univariate numerical summaries will be:

Statistics > Summaries >

Active data set [Mixed]

Numerical Summaries [Quantitative]

Frequency distributions [Qualitative]

Our bivariate numerical summaries will be:

Statistics > Summaries >

Correlation matrix... [Quantitative]

Statistics > Contingency tables >

Two-way table [Qualitative]

Multi-way table [Qualitative]

Create z-scores

**The Pivot Table for**

contingency tables

conditional summaries

contingency tables

conditional summaries

Select one or more "margins" for the rows and columns.

Report filter creates a "condition" for the resulting table/matrix.

**Choose values to fill in the matrix/table.**

Select a data range.

The displayed quantities can be changed.

Click the Pivot Table button.