开发者

what are the meaning of these R notes

开发者 https://www.devze.com 2023-01-13 06:30 出处:网络
I read a R code on loess regression, here is part of it: f.lo<- loess(bgs ~ f[,1], span=bw,开发者_运维百科 degree=1)

I read a R code on loess regression, here is part of it:

f.lo<- loess(bgs ~ f[,1], span=bw,开发者_运维百科 degree=1)
bsln <- f.lo$fitted

What are their functions: bgs~f[,1] , the ~ and the $ in the next line? thanks


Tilde ~ creates a formula, $ extracts the fitted element from S3 object (so de-facto list) created by loess. You can find more details in R-intro.


mbq's answer is correct, but I'll just add this:

> `~`(y, x)
y ~ x
> class(`~`(y, x))
[1] "formula"
> terms(`~`(y, x))
y ~ x
attr(,"variables")
list(y, x)
attr(,"factors")
  x
y 0
x 1
attr(,"term.labels")
[1] "x"
attr(,"order")
[1] 1
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1
attr(,".Environment")
<environment: R_GlobalEnv>
> 
0

精彩评论

暂无评论...
验证码 换一张
取 消