我是R语言的新手,正在尝试将绘图转换为ggplot。
plot(res$s, type="n", main=title)
print(lines(res$s))
res$s
输出结果
2014-02-14 51.8460
2014-02-14 44.5080
library(ggplotify)
res<-read.table(text="
s
\"2014-02-14 51.8460\"
\"2014-02-14 44.5080\" ", header=T)
p <- as.ggplot(function() plot(res$s, type="n", main="title") )
p
您无法从基本的R图形转换为ggplot2。您必须重新绘制数据。ggplot2提供了一个名为qplot()
的函数,其语法类似于plot()
。
如果您有一个两列的数据框:df$x和df$y,
qplot(df$s,df$y, geom='line')
应该做你想要的。
ggplot
代替plot
。你目前尝试了什么?能给我们提供一个最小可复现示例吗? - user3603486