r - Combining two ecdf plots with different -
at moment i`m writing bachelor thesis , of plots created ggplot2. need plot of 2 ecdfs problem 2 dataframes have different lengths. adding values equalize length change distribution, therefore first thought isn't possible. ecdf plot 2 different dataframes different length forbidden.
daten <- peptidpsmotherexplained[peptidpsmotherexplained$v3!=-1,] daten <- cbind ( daten , "scoredistance"= daten$v2-daten$v3 ) daten2 <- peptidpsmotherexplained2[peptidpsmotherexplained2$v3!=-1,] daten2 <- cbind ( daten2 , "scoredistance"= daten2$v2-daten2$v3 ) p <- ggplot(daten, aes(x = scoredistance)) + stat_ecdf() p <- p + geom_point(aes(x = daten2$lengthdistance)) p
with normal plot function of r possible
plot(ecdf(daten$scoredistance)) plot(ecdf(daten2$scoredistance),add=true)
but looks different of other plots , dislike this.
has solution me?
thank you, tobias
example:
df <-data.frame(scoredifference = rnorm(10,0,12)) df2 <- data.frame(scoredifference = rnorm(5,-3,9)) plot(ecdf(df$scoredifference)) plot(ecdf(df2$scoredifference),add=true)
so how can achieve kind of plot in ggplot?
i think, reshaping data in right way make ggplot2 work you:
df <-data.frame(scorediff1 = rnorm(10,0,12)) df2 <- data.frame(scorediff2 = rnorm(5,-3,9)) library('reshape2') data <- merge(melt(df),melt(df2),all=true)
then, data
in right shape, can go on plot stuff colour (or shape, or whatever wish) distinguish 2 datasets:
p <- ggplot(daten, aes(x = value, colour = variable)) + stat_ecdf()
hope looking for!?
Comments
Post a Comment