library(gtrendsR)
library(ggplot2)
usr <- "xxxxxx@gmail.com"
psw <- "XXXXX"
gconnect(usr, psw)
climate_trend <- gtrends(c("climate", "cop21", "global warming"), res="week")
plot(climate_trend, main="whatttt", xlab="x")尽管没有收到错误,但使用main=或xlab=等绘图编辑选项不会在绘图输出中创建更改。我曾考虑过将ggplot2与gtrendsR结合使用,但这需要我将list数据转换为我遇到麻烦的data.frame。
我很欣赏使用gtrendsR编辑绘图输出的轴的任何输入。
发布于 2015-12-31 17:17:14
您可能感兴趣的数据框架只是climate_trend$trend元素。下面是我为获得一个ggplot2图所做的工作:
library(gtrendsR)
library(ggplot2)
library(reshape2)
usr <- "xxxx@gmail.com" # any gmail address and pw will do here
psw <- "xxxxx"
gconnect(usr, psw)
climate_trend <- gtrends(c("climate", "cop21", "global warming"), res="week")
# plot(climate_trend$trend, main="whatttt")
# now for ggplot 2
tdf <- climate_trend$trend
mdf <- melt(tdf,id.vars=c("start","end"))
ggplot(data=mdf,aes(x=start,y=value,color=variable)) +
geom_line() + geom_point() +
labs(title="Whatttt")

https://stackoverflow.com/questions/34549009
复制相似问题