I get the following error when I try to modify the names of the object
returned by get(). Does anybody know how to do so? (I could use as.vector()
to remove the names, but I'm interested in how to modify the object returned
by get().)
$ cat main_get_name_assign.R
x=1:10
names(x)=letters[1:10]
Hi John,
Probably there is a more elegent solution, but I usually do something like
tmp - get(x)
names(tmp) - letters[1:10]
assign(x, tmp)
rm(tmp)
HTH,
Ista
On Tue, Feb 15, 2011 at 11:43 AM, John Edwards jhnedwards...@gmail.com wrote:
I get the following error when I try to modify the names of
On 15/02/2011 11:43 AM, John Edwards wrote:
I get the following error when I try to modify the names of the object
returned by get(). Does anybody know how to do so? (I could use as.vector()
to remove the names, but I'm interested in how to modify the object returned
by get().)
You can
You can probably do this by constructing a call to the `names-` replacement
function, but it's really bad style. Don't write R code that has external
side effects if you can avoid it. In this case, you'll almost certainly get
more maintainable code by writing your function to return a copy
4 matches
Mail list logo