Skip to content

MANE 6313

Week 2, Module E - Univariate Data Creation and Analysis

Module E will focus on univariate data creation and analysis. An excellent resource for the data analysis portion of this module is the Stats and R Blog.


Data Creation

  • R stores a single variable in a vector
  • There are two primary ways to create univariate data in R:
  • c() function
  • functions that create data such as rnorm
  • Use example datasets in R (not covered)

c() Function

  • Most common way to create univariate data

c() Function Example


rnorm Function

  • Built-in function to generate n random normal observations with mean value of mean and standard deviation of sd
  • Mean and sd are optional arguements and default to values of 0 and 1 respectively
  • rnorm(n,mean,sd)

rnorm Function Example

Descriptive Statistics

  • Descriptive statistics refer to the values of numerical functions applied to data. Examples of descriptive statistics include mean, median, mode, standard deviation, variance, range, IQR, etc.
  • Descriptive statistics in R include:
  • summary()
  • describe()

Summary Function

Summary Function


Describe

  • Adds more statistics to report
  • Requires the package psych to be installed
  • Additional information can be found here

Describe Example


Describe example

Graphical Analysis

  • Histogram, Boxplot, Stem and Leaf, Line plot, QQ-plot, QQ-plot with bands

Histogram

Histogram Example


Boxplot

Boxplot Example


Stem-and-Leaf Diagram

Stem Example


Line Plot

Line Plot Example


QQ-Plot

  • Simple Normal Probability Plot

QQplot


QQ-Plot with Probability Bands

  • Requires package car to be installed

QQ-plot with probability bands