标签:r语言
环境和函数> an_environment[["pythag"]] <- c(12,15,20,21)> an_environment$root <- polyroot(c(6,-5,1))> assign("moonday",weekdays(as.Date("1969/07/20")),an_environment)
> an_environment$root[1] 2+0i 3-0i> get("moonday",an_environment)[1] "星期日"
> ls(an_environment)[1] "moonday" "pythag" "root"> ls.str(an_environment)moonday : chr "星期日"pythag : num [1:4] 12 15 20 21root : cplx [1:2] 2+0i 3-0i
> (a_list <- as.list(an_environment))$pythag[1] 12 15 20 21$moonday[1] "星期日"$root[1] 2+0i 3-0i> as.environment(a_list)<environment: 0x0000000005ed8d50>
> a_function <- function(x,y)+ {+ sqrt(x^2+y^2)+ }> a_function(2,4)[1] 4.472136
> do.call(a_function,list(x=2,y=1))[1] 2.236068
标签:r语言
原文地址:http://blog.csdn.net/luoyhang003/article/details/38348251