I still think that fortune(181) applies here. Someday you (or another user
that you give your function to) will run this, then realize that you/they had
an A, B, or c variable that has just been overwritten that you/they wanted to
keep. (also 'c' is one of the variable names recommended agains
As a followup to my question yesterday, what if I were to return the
argument as a list, and then "unwrap" the list with the function I've
written called "objects". Is there any problems with doing it? It
works to use it inside other functions. For example:
=
>
For your last question, the function 10 needs to be defined inside of function
nine (lexical scoping), something like:
nine <- function(a) {
ten <- function(d) {
b <<- 10
print(paste("(ten) b=",b))
print(paste("(ten) d=",d))
d
}
b <- 9
ten(a)
print(paste("(nine) b=",b)
I don't know why you want to do this. But you can try _assign_
simple <- function(m,n) {
assign("A",matrix(c(3,3,2,3),2,2),env=.GlobalEnv)
assign("B",m,env=.GlobalEnv)
assign("c",1:n,env=.GlobalEnv)
}
> simple(5,4)
> A
[,1] [,2]
[1,]32
[2,]33
> B
[1] 5
Ronggui
2009/6/3 Sc
4 matches
Mail list logo