Variable mass declaration and assignment in R?

Sorry if this is a stupid question, but this is my first attempt at using R , and I ended up writing the code line by line:

 some <- vector('list', length(files)) thing <- vector('list', length(files)) and <- vector('list', length(files)) another <- vector('list', length(files)) thing <- vector('list', length(files)) 

Is there a nicer (DRY) way to do this in R ?

To rephrase, I want to assign the same value to several variables at once (according to @Sven Hohenstein's answer)

+4
source share
1 answer

If you want to assign the same value to multiple variables at once, use this:

 some <- thing <- and <- another <- thing <- vector('list', length(files)) 
+15
source

Source: https://habr.com/ru/post/1446061/


All Articles