Using paste() Function to Create New Variable in R (Example Code)
In this R programming tutorial you’ll learn how to apply the paste function to create a new variable name.
Example: Creating New Variable Using paste0() & assign()
assign(paste0("x", 1), 100:110) # Applying assign & paste0 |
assign(paste0("x", 1), 100:110) # Applying assign & paste0
x1 # Printing variable to RStudio console # [1] 100 101 102 103 104 105 106 107 108 109 110 |
x1 # Printing variable to RStudio console # [1] 100 101 102 103 104 105 106 107 108 109 110