I'm trying to create a plot showing the temporal evolution (x) of different values from the same column (y), thus requiring to create a plot with different lines. I am able to create separate plots for each value of y, so my problem seems to be specifically about adding multiple lines showing different values (of different lengths it seems).
This is the dput of the columns "Date" and "Journal" I use from my dataset "test" :
> structure(list(Date = structure(c(9132, 9136, 9136, 9141, 9141,
9142), class = "Date", tzone = "Europe/Paris"), Journal = c("Libération",
"Libération", "Libération", "Libération", "Le Monde", "La Tribune (France)"
)), row.names = c(NA, -6L), .internal.selfref = <pointer: 0x000002146c471ef0>, class = c("data.table",
"data.frame"))
I used the following code to successfully create a barplot which shows the evolution of column "Journal" according to the column "Date".
dateplot <- ggplot(cleantest) + aes(x = format(Date, "%Y%")) + geom_bar()
I also managed to create single line plots for each value of Y, with the following code :
valueplot <- ggplot(subset(test, Journal %in% "value")) + aes(x = format(Date, "%Y")) + geom_line(stat = "count", na.rm = TRUE, group = 1)
Therefore, I typed the following codes to obtain, for example, two lines in the same plot, and each of them returned a different error :
jourplot <- ggplot(test, aes(x = format(Date, "%Y"))) + geom_line(aes(y = subset(test, Journal %in% "Libération"), colour = "blue")) + geom_line(aes(y = subset(test, Journal %in% "Le Figaro"), colour =
"red"))
The error is :
> Don't know how to automatically pick scale for object of type data.table/data.frame. Defaulting to continuous. Erreur : Aesthetics must be either length 1 or the same as the data (17307): y
So I tried this :
jourplot <- ggplot(test, aes(x = format(Date, "%Y")) + geom_line(aes(y = subset(test, Journal %in% "Libération"), colour = "blue"), stat = "count", na.rm = TRUE, group = 1) + geom_line(aes(y = subset(test, Journal %in% "Le Figaro"), colour = "red"), stat = "count", na.rm = TRUE, group = 1"))
But this one doesn't even create the "jourplot" object. There is obviously something wrong with my code and / or my data, but as a newbie I really don't see it. It seems to be about length, but how do I get over this ? Or is this about the classes of the columns that make things difficult to process for ggplot ?
Does anyone understand what is going on ?
Edit : I deleted the "+" symbols from prompt

+are symbols you actually typed, and which are command prompts? Remove those which are command propmts.