Sergio.pv
Sergio.pv

Reputation: 1400

How to assign a name to an object when the name is stored in a different vector

Given these two objects:

v <- "new.name"

w <- 1:10

How can I tell R to rename w as new.name, so I can have this

  > new.name
 [1]  1  2  3  4  5  6  7  8  9 10

Thanks

Upvotes: 2

Views: 64

Answers (1)

David Arenburg
David Arenburg

Reputation: 92310

You could do

assign(v, w)
new.name
# [1]  1  2  3  4  5  6  7  8  9 10

But it is considered a very bad practice in R, so read this first

Upvotes: 6

Related Questions