Re: [R] how to add names to an object created using assign

2009-02-20 Thread David Winsemius
At this point, the function would only return the names because unless specified otherwise they return the result of the last evaluation. Add another line with just "a" and assign the results of the function to something: > testold=function(){ + assign("a",c(1,2,3),env=.GlobalEnv) + names(a

[R] how to add names to an object created using assign

2009-02-20 Thread Fuchs Ira
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: t