Scaling in R
&
ggplot + forecast
Ed Goodwin
Houston R Users Group
What is scaling?
Scaling is when you need to transform a dataset to
another size scale…usually to analyze with a
another data set
Example: comparing two survey datasets with
different scoring mechanisms
It allows you to measure the relative effects of
datasets on different scales
Let’s make some samples
How do we common-size our
samples?
• With the scale( ) function
• scale( ) allows you to scale and center the data
Scaling
Divide all column values
by the standard deviation
to arrive at a common
scaling
Centering
Subtract all column values
from the column mean to
get
a common center value
Centered & Scaled
You could also do this
yourself (z-transform)
Forecast + ggplot
Recent updates to Rob Hyndman’s forecast
package include ability to use ggplot for plotting
time series forecasts.
See http://robjhyndman.com/hyndsight/forecast7-
ggplot2/ for more details
Using ggplot with time series
use autoplot( ) function with time series objects to
create ggplot graphics.

Scaling in R

  • 1.
    Scaling in R & ggplot+ forecast Ed Goodwin Houston R Users Group
  • 2.
    What is scaling? Scalingis when you need to transform a dataset to another size scale…usually to analyze with a another data set Example: comparing two survey datasets with different scoring mechanisms It allows you to measure the relative effects of datasets on different scales
  • 3.
  • 4.
    How do wecommon-size our samples? • With the scale( ) function • scale( ) allows you to scale and center the data
  • 5.
    Scaling Divide all columnvalues by the standard deviation to arrive at a common scaling
  • 6.
    Centering Subtract all columnvalues from the column mean to get a common center value
  • 7.
  • 8.
    You could alsodo this yourself (z-transform)
  • 9.
    Forecast + ggplot Recentupdates to Rob Hyndman’s forecast package include ability to use ggplot for plotting time series forecasts. See http://robjhyndman.com/hyndsight/forecast7- ggplot2/ for more details
  • 10.
    Using ggplot withtime series use autoplot( ) function with time series objects to create ggplot graphics.