Last active
August 4, 2018 00:58
-
-
Save coolbutuseless/e6ec9db77848ffcf781445c72c08385c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# ggplot2: Bug or Feature? | |
# | |
# Problem: stat_summary is calculated after axes are transformed. | |
# | |
# Expected: | |
# Median at x=0 is 0, and median at x=1 is 1 | |
# Expect line from (0, 0) to (1, 1) | |
# | |
# Actual | |
# Get a line from (0, 1) to (1, 1) | |
# Because y values are log transformed first, | |
# any zero values get replaced with Inf. These | |
# Inf values are then excluded from the median calculation | |
# such that the median at x=0 is the median(1) = 1 | |
# | |
# Is there an option to have stat_summary calculated before axis transform? | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
df = data.frame( | |
x = c(0,0,0, 1,1,1), | |
y = c(0,0,1, 1,1,1)) | |
ggplot(df, aes(x, y))+ | |
stat_summary(fun.y=median,geom='line')+ | |
scale_y_log10() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment