Skip to content

Instantly share code, notes, and snippets.

@thigm85
Last active December 27, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save thigm85/7352137 to your computer and use it in GitHub Desktop.
Save thigm85/7352137 to your computer and use it in GitHub Desktop.
require(ggplot2)
require(gridExtra)
require(reshape2)
set.seed(1)
predictors = data.frame(x1 = rnorm(1000, mean = 5, sd = 2),
x2 = rexp(1000, rate=10))
p1 = ggplot(predictors) + geom_point(aes(x = x1, y = x2))
temp <- melt(predictors, measured = c("x1", "x2"))
p2 = ggplot(temp) + geom_histogram(aes(x=value)) +
facet_grid(. ~ variable, scales = "free_x")
grid.arrange(p1, p2)
require(caret)
trans <- preProcess(predictors, c("BoxCox", "center", "scale"))
predictors_trans <- data.frame(trans = predict(trans, predictors))
p1 = ggplot(predictors_trans) + geom_point(aes(x = trans.x1, y = trans.x2))
temp <- melt(predictors_trans, measured = c("trans.x1", "trans.x2"))
p2 = ggplot(temp) + geom_histogram(aes(x=value), data = temp) +
facet_grid(. ~ variable, scales = "free_x")
grid.arrange(p1, p2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment