【发布时间】:2014-05-17 03:09:01
【问题描述】:
我有以下函数用于将非线性曲线拟合到一组数据。我不断收到以下错误:
Error in do.call("layer", list(mapping = mapping, data = data, stat = stat, :
object 'y' not found
错误来自geom_smooth 配合。你能提供建议吗?
下面是一些测试数据和功能:
library("ggplot2")
DF <- data.frame(RFP_fold=1:20, E=rnorm(20))
flimPlot <- function(data) {
ggplot(data, aes(x=RFP_fold, y=E)) +
geom_point(shape=1) +
geom_smooth(method=nls, # Add non linear regression fit
formula='y ~ a * (x / (x + K))', # Forumla for fit
start=list(a=max(y), K = 0.1), # set the parameters
se = FALSE, # No shaded CI
fullrange=TRUE) # Extend regression line
}
flimPlot(DF)
# Error in do.call("layer", list(mapping = mapping, data = data, stat = stat, :
object 'y' not found
【问题讨论】:
-
你的意思是
start=list(y=max(a), K = .1),还是你的意思是start=list(a=max(a), K=.1)? -
@BenBolker 你说得对,我的意思是第二种方式。在提交问题之前,我一直在玩弄语法。
-
@BenBolker,在我修正错字后它仍然失败。我还添加了一些可重现的数据。我不断收到 y not found 错误。