Using ggplot2 to plot multiple lines in one R plot -


i trying use ggplot2 plot multiple lines in 1 r plot have problem , not able to. first question here. learning how use r studio , package don't know please patient. code wrote:

library(ggplot2)  x <- 1:10 y1 <- dati.m$with.no.educational.qualifications y2 <- dati.m$compulsory.education..1st.cycle y3 <- dati.m$compulsory.education..2nd.cycle y4 <- dati.m$compulsory.education..3rd.cycle y5 <- dati.m$upper.secondary.education y6 <- dati.m$higher.education df <- dati.m(x, y1, y2, y3, y4, y5, y6) ggplot(df, aes(x)) +   geom_line(aes(y=y1),             colour="red") +   geom_line(aes(y=y2),             colour="green") +   geom_line(aes(y=y3),             colour="blue") +   geom_line(aes(y=y4),             colour="yellow") +   geom_line(aes(y=y5),             colour="orange") +   geom_line(aes(y=y6),             colour="black") 

but when execute r, error:

error: aesthetics must either length 1 or same data (17): y, x

i replaced df <- dati.m(x, y1, y2, y3, y4, y5, y6) df <- data.frame(x, y1, y2, y3, y4, y5, y6)

if use code:

library(ggplot2)  x <- 1:10 y1 <- 1:10 y2 <- 2:11 y3 <- 3:12 y4 <- 4:13 y5 <- 5:14 y6 <- 6:15 df <- data.frame(x, y1, y2, y3, y4, y5, y6) ggplot(df, aes(x)) +         geom_line(aes(y=y1),                   colour="red") +         geom_line(aes(y=y2),                   colour="green") +         geom_line(aes(y=y3),                   colour="blue") +         geom_line(aes(y=y4),                   colour="yellow") +         geom_line(aes(y=y5),                   colour="orange") +         geom_line(aes(y=y6),                   colour="black") 

you :

enter image description here


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -