I want to create an ecdf plot with two lines and I would like to add errorbars to one of them.
I am using this code
x <- c(16,16,16,16,34,35,38,42,45,1,12)
xError <- c(0,1,1,1,3,3,3,4,5,1,1)
y <- c(16,1,12)
length(x)
length(xError)
length(y)
df <- rbind(data.frame(value = x,name='x'),
data.frame(value = y,name='y'))
ggplot(df, aes(x=value,color=name,linetype=name))+ stat_ecdf()+ geom_errorbar(aes(ymax = x + xError, ymin=x - xError))
The error bar should be added to the x values, but it gives my this error:
Error: Aesthetics must either be length one, or the same length as the dataProblems: x + xError, x - xError
I don't get it - the result is of the same length.
EDIT
I changed to problem, so it gets easier - I thin the real problem is related to ECDF plots and error bars. Take this code as an example:
x <- c(16,16,16,16,34,35,38,42,45,1,12)
xError <- c(0,1,1,1,3,3,3,4,5,1,1)
y <- c(16,1,12)
df <- data.frame(value = x)
ggplot(df, aes(x=value))+ stat_ecdf()+ geom_errorbar(aes(ymax = x + xError, ymin=x - xError))
It prints the error bars, but the plot is completely broken.