![f100b97b2e5be56c36780b54442b6779.png](https://i-blog.csdnimg.cn/blog_migrate/9b52512fae007b4405275ad15be53a71.jpeg)
![454c4fcecadbb30ded58de0665b234ff.png](https://i-blog.csdnimg.cn/blog_migrate/f18c69eefa2124a6c6fdbaaee69a3fac.png)
固定参数函数
f1 <- function(a,b=2){
message(a,b)
return(a+b) # 没有return返回最后一条语句
}
b <- f1(5) # 52
b # 7
f1(2,5) # 25
f1(b=2,a=5) # 52
f1(b=5,2) # 25
可变参数的函数
r自带函数 c(..., recursive = FALSE, use.names = TRUE)
f2 <- function(...){
cat(..2) # 2
dot_args = list(...)
print(dot_args)
}
f2(1,2,3,4,5)
一切都是对象
操作符也是函数类型对象