Hi everyone! Today me and my colleagues had some problem with ggplot. Actually we have to do an assignment and the answer says 'Make the scatter plots in ggplot2 as in the script on openness' and so we wrote on R '
p <- qplot(x = gravity.ita$ldistw, y = gravity.ita$lflow, data=gravity.ita, colour=gravity.ita$lgdp_d) + theme_bw() + labs(title="gravity.ita", x="log of distance", y="log of exports",color="lgdp_d")
p
p + stat_smooth(method = "gam", formula = y ~ s(x, k = 10), size = 1)
#6-7
p <- qplot(x = gravity.ita$lgdp_d, y = gravity.ita$lflow, data=gravity.ita, colour=1/gravity.ita$ldistw) + theme_bw() + labs(title="gravity.ita", x="log of GDP of importing country", y="log of exports",color="1/ldistw")
p
p + stat_smooth(method = "gam", formula = y ~ s(x, k = 10), size = 1)
but then, when we went to knit the all work with word, we have this message from R Markdown
'Quitting from lines 130-137 (Homework1.Annmarkdown.ultimo.Rmd)
Error in qplot(x = gravity.ita$ldistw, y = gravity.ita$lflow, data = gravity.ita, :
non trovo la funzione "qplot"
Calls: ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Esecuzione interrotta'
p <- qplot(x = gravity.ita$ldistw, y = gravity.ita$lflow, data=gravity.ita, colour=gravity.ita$lgdp_d) + theme_bw() + labs(title="gravity.ita", x="log of distance", y="log of exports",color="lgdp_d")
using ggplot2 would look like
p <- ggplot(gravity.ita,aes(x = ldistw, y = lflow)
to make a base plot, which can then be elaborated with other features.
library(ggplot2)
p <- ggplot(mtcars,aes(x = mpg, y = hp))
p + geom_point(color = "red") +
ggtitle("Scatterplot of hp against mpg in mtcars data") +
theme_bw()
I don't have it I've just check it! Thank you so much! How can I do to add it to my files? I have already done quite all my job, is there a way to add it on my file without start again from the beginning?