我想知道这是否是一个错误。
我有以下代码:
h2 <- hist(c(rep(65, times=5), rep(25, times=5), rep(35, times=10), rep(45, times=4)))
model2 = nls(formula = log(counts[1:5]) ~a+log(mids[1:5])*gamma, start=list(gamma=-3,a=10),data=h2)
它因错误而中断:
Error in parse(text = x) : <text>:2:0: unexpected end of input
1: ~
^
但如果我这样做:
h2 <- hist(c(rep(65, times=5), rep(25, times=5), rep(35, times=10), rep(45, times=4)))
model2 = nls(formula = log(counts[1:5]) ~a+log(breaks[1:5])*gamma, start=list(gamma=-3,a=10),data=h2)
它没有给出错误(它不能适合这个特定的数据,但可以适合我真正拥有的数据)。
问题是,对于我正在做的工作,我需要直方图间隔的中间,而不是休息时间。
编辑:错误后,回溯是:
7: parse(text = x)
6: eval(parse(text = x)[[1L]])
5: formula(eval(parse(text = x)[[1L]]))
4: formula.character(object, env = baseenv())
3: formula(object, env = baseenv())
2: as.formula(paste("~", paste(varNames[varIndex], collapse = "+")),
env = environment(formula))
1: nls(formula = log(counts[1:5]) ~ a + log(mids[1:5]) * gamma,
start = list(gamma = -3, a = 10), data = h2)