【发布时间】:2017-12-05 03:52:51
【问题描述】:
我有这样的功能:
fun <- function(dataset){
require(ggplot2)
g <- ggplot(dataset, aes(x = x, y = y)) + geom_smooth(method = "lm") + geom_point()
l<-lm(y~x)
return (list(l, g))
}
我想返回绘图和值,但它不返回绘图并且我遇到了这个错误:
.Call.graphics(C_palette2, .Call(C_palette2, NULL)) 中的错误:
无效的图形状态
我能做什么?
【问题讨论】:
-
请先提供Minimal Complete and Verifiable Example。没有它,很难找出问题所在。我确实在 return 语句中看到了一个错字(
g而不是p),但这不应该是主要问题,我认为。 -
你想让这些值出现在图上吗?
-
会好很多,但我的问题是关于在控制台中打印值
标签: r function plot ggplot2 lm