先上代码
>library(Formula)
>formula <- y ~ a/(1+exp(b*log(x) +c))
>a = 133
>b = 1
>c = -5
>x = c(1:100000)
>Fformula = Formula(formula)
>rFformula = attributes(Fformula)
>fyData = eval(rFformula$rhs[[1]])
>plot(fyData~x,log = "x",col = "RED")
- Formula: class Formula extends the base class formula by allowing for multiple responses and multiple parts of regressors. 也就是说大Formula 是对小formula(即原公式功能的拓展),所以必须得用。
- eval函数: 评估指定式子和返回值计算
- 可以自己查看rFormula内容
还不太会predict直接作图,在学习中
图片,其中x轴已经显示为 log scale
本文通过使用R语言中的Formula包展示如何绘制带有log x轴的曲线。代码中定义了一个特殊的数学公式,并利用eval函数计算出y值,最终将数据绘制成图表。介绍了Formula包相较于标准formula的优势以及eval函数的基本用途。
866

被折叠的 条评论
为什么被折叠?



