assign函数在循环时候,给变量赋值,算是比较方便
举例说明:
1、
for (i in 1:(length(rowSeq)-1)){ assign(paste("nginx_server_fields7_", i, sep = ""), nginx_server_fields7[(rowSeq[(i-1)+1]):(rowSeq[i+1]), ]) }
2、小例子
for (i in 1:3){ assign(paste("a", i, sep = ""), i:10) } ls() [1] "a1" "a2" "a3" "i" > a1 [1] 1 2 3 4 5 6 7 8 9 10 > a2 [1] 2 3 4 5 6 7 8 9 10
时间: 2024-10-19 03:31:53