我试图创建一个接受两个参数的简单函数:
的线性模型和对应于一种颜色,在该顺序的字符串。
它应为此创造线性模型的残差VS合身而QQ图和彩色之分,根据字符串参数是这样的:
demo_lm < - LM(ExpenditurePerStud〜国家,数据= clean_colleges)
answer7(demo_lm, “#34925E”)
这是我曾尝试:
library(ggplot2)
demo_lm <- lm(ExpenditurePerStud ~ State, data = clean_colleges)
answer7 <- function( my_lm , color_str)
{
autoplot(my_lm, which = 1:2, smooth.colour = color_str,
data = clean_colleges, colour = color_str) +
theme_bw()
}
但它抛出的错误:当我打电话型LM的对象不自动绘制支持answer7(demo_lm, "#34925E")