If I assign a variable in a function, as in:
test=function(){
assign("a",c(1,2,3),env=.GlobalEnv)
}
How can I do the equivalent of:
names(a)=c("one","two","three")
within the function?
Merely adding the call to names does not work within the function as
it only affects a local variable:
test=function(){
assign("a",c(1,2,3),env=.GlobalEnv)
names(a)=c("one","two","three")
}
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.