Reputation: 7592
If I have a named vector, and I'm trying to assign it into a new vector, but there I want it to have a different name, is there a way to avoid it coming out in the format newname.oldname
, forcing me to rename()<-
it manually?
Example:
a<-c(foo="baz")
a
# foo
# "baz"
b<-c(baz=a)
b
# baz.foo
# "baz"
I want to make it so b
's name is only "baz", without the ".foo". Is there a way to achieve that directly?
Upvotes: 2
Views: 45
Reputation: 887173
We can do unname
or as.vector
c(baz = unname(a))
# baz
#"baz"
Also with dplyr::lst
, we can automatically name after unname
ing
dplyr::lst(!!unname(a))
Upvotes: 2