Scaling in R

Post on 14-Feb-2017

71 views 0 download

Transcript of Scaling in R

Scaling in R &

ggplot + forecastEd 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 seriesuse autoplot( ) function with time series objects to create ggplot graphics.