Back
Close

Computing with Data

elgeish
31.1K views
Previous: Outliers Next: Skewness and Power Transformation - Part II

Skewness and Power Transformation - Part I

# Example 1 - the diamonds dataset
head(diamonds)
summary(diamonds)
# Example 2 - the price histogram of a random subset of 1000 diamonds
diamondsSubset = diamonds[sample(dim(diamonds)[1], 1000), ]
qplot(price, data = diamondsSubset)
# Example 3 - a transformed histogram
qplot(log(price), size = I(1), data = diamondsSubset)
# Example 4 - transforming both variables
qplot(carat,
price,
size = I(1),
data = diamondsSubset)
qplot(carat,
log(price),
size = I(1),
data = diamondsSubset)
qplot(log(carat),
price,
size = I(1),
data = diamondsSubset)
qplot(log(carat),
log(price),
size = I(1),
data = diamondsSubset)
# Example 5 - display the original un-transformed variables on logarithmic axes
qplot(carat,
price,
log = "xy",
size = I(1),
data = diamondsSubset)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants