string - Convert Variables to characters in R -


i want take names of variables in a , results in b

a <- list(eurusd,usdjpy,cadjpy)  b <- c("eurusd", "usdjpy", "cadjpy") 

how can instead of writing manually?

first, r evaluates lazily, when assigned list variable a expression list(eurusd, usdjpy, cadjpy) got evaluated. unless 3 objects named , have same names, not possible names.

what try parse output of ls(): 6 character caps names in namespace.

example:

eurusd <- runif(10) usdjpy <- runif(10) cadjpy <- runif(10)  blablabla <- 'unused variable'  currency_pairs <- ls(pattern='^[a-z]{6}$') print(currency_pairs) [1] "cadjpy" "eurusd" "usdjpy" 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -