r - Strange behaviour in c() -


why can't use paste construct string in c()?

c("somekey" = 123) 

is ok , prints as:

somekey      123  

but

a1 <- "some" a2 <- "key" c(paste(a1, a2) = 123) 

produces:

error: unexpected '=' in "    c(paste(a1, a2) =" 

strangely enough, can this:

key <- paste(a1, a2) c(key = 123) 

you looking setnames, returns named vector specified names , values:

setnames(123, paste0(a1, a2)) # somekey  #     123  all.equal(setnames(123, paste0(a1, a2)), c("somekey" = 123)) # [1] true 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -