参考手册
参考手册
实例 R 语言 在函数中创建全局变量
源代码
运行代码
my_function <- function() { txt <<- "fantastic" paste("R is", txt) } my_function() print(txt)
x
my_function
<-
function
() {
txt
<<-
"fantastic"
paste
(
"R is"
,
txt
)
}
my_function
()
print
(
txt
)
输出结果
[1] "R is fantastic"
[1] "fantastic"