Reputation: 107
Question: Plot appears in rmarkdown but does not knit. Two errors appear. no other issues with the file.
Line 239 Error in parse(text = x, scrfile = src) : ,text>:4:16: unexpected ' , '
3: alpha = 0.9, width = 7) + theme_minimal(base_size = 8) + #Note minimal theme alpha
4: alpha = 0.9
Calls: ... -> parse_all -> parse_all.character -> parse
I have changed a lot to make it work, including alpha and confirmed the code is linked correctly to its dependencies. I have made sure dplyr is in library (read it in other solution that did not work for me). I cannot see the issue as the plot works in rstudio and shows in rmarkdown and it did not knit
This is the chunk that is in rmarkdown linked to the error
#next line is line 239
ONE1 <- ggplot(Italy, aes(Date, as.numeric(FirstDosePC))) +
geom_col(fill = "red", alpha = .9, width = 7) + theme_minimal(base_size = 8) +
#Note minimal theme
xlab(NULL) + ylab(NULL) + scale_x_date(date_labels = "%Y/%m/%d")
OneTwo <- ONE1 + geom_col(data=Ireland, aes(Date,
as.numeric(FirstDosePC)),
fill="Green", alpha = .9,width = 5)
OneTwoThree <- OneTwo + geom_col(data=Latvia, aes(Date,
as.numeric(FirstDosePC)),
fill="black", alpha = .9, width = 2)
OneTwoThree + labs(title="Ireland, Italy, & Latvia - First Dose comparision",
subtitle="ITALY = RED, IRELAND = GREEN, LATVIA = BLACK",
caption = "(ECDC, 2021)",
x="Date Administered",
y="% Population treated")
Upvotes: 0
Views: 283
Reputation: 107
Noob mistake. I had a comment in the first piece of the chunk that allowed the plot to be built in both rmarkdown and the r workspace.
BUT the comment # was stopping the knitting process.
Removed comment - knitting happened (removed #Note minimal theme ... to help you see the solution)
BEFORE
ONE1 <- ggplot(Italy, aes(Date, as.numeric(FirstDosePC))) +
geom_col(fill = "red", alpha = .9, width = 7) + theme_minimal(base_size = 8) +
#Note minimal theme
xlab(NULL) + ylab(NULL) + scale_x_date(date_labels = "%Y/%m/%d")
AFTER
ONE1 <- ggplot(Italy, aes(Date, as.numeric(FirstDosePC))) +
geom_col(fill = "red", alpha = .9, width = 7) + theme_minimal(base_size = 8) +
xlab(NULL) + ylab(NULL) + scale_x_date(date_labels = "%Y/%m/%d")
Upvotes: 1