Hi Marna,

here is another example that should appear more similar to your scenario
than my previous one.

x <- seq(1:100)

y1 <- x*x
g1 <- rep("y1", 100)
df1 <- as.data.frame(cbind(x, y1), stringsAsFactors=FALSE)
df1 <- as.data.frame(cbind(df1, g1))
colnames(df1)<- c("x", "value", "variable")

y2 <- y1+1500
g2 <- rep("y2", 100)
df2 <- as.data.frame(cbind(x, y2), stringsAsFactors=FALSE)
df2 <- as.data.frame(cbind(df2, g2))
colnames(df2)<- c("x", "value", "variable")

y3 <- y1+6000
g3 <- rep("y3", 100)
df3 <- as.data.frame(cbind(x, y3), stringsAsFactors=FALSE)
df3 <- as.data.frame(cbind(df3, g3))
colnames(df3)<- c("x", "value", "variable")

avg <- (y1+y2+y3)/3
df4 <- as.data.frame(cbind(x, avg))
g4 <- rep("average", 100)
df4 <- as.data.frame(cbind(df4, g4))
colnames(df4) <- c("x", "value", "variable")

df <- data.frame(rbind(df1, df2, df3, df4))

# this is the data to start with ggplot()
df

# the df rows where the average value is stored
sel <- which(df[,"variable"]=="average")

library(ggplot2)

ggplot(data = df[-sel,], aes(x=x, y=value, group=variable)) + geom_line() +
  geom_line(data = df[sel,], aes(x=x, y=value, group=variable), size=0.5, 
linetype="dashed", color="blue")


Merry Christmas,

--
GG


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to