Basically I want to be able to do this.
a <- 1
data_frame_1 <- "some data"
a <- a+1
data_frame_2 <- "some data"
Where the 1 and 2 at the end of the data frame names are coming from the values of a. Is there a way to do this?
Basically I want to be able to do this.
a <- 1
data_frame_1 <- "some data"
a <- a+1
data_frame_2 <- "some data"
Where the 1 and 2 at the end of the data frame names are coming from the values of a. Is there a way to do this?
As a simple example:
my_list <- list(data_frame_1,data_frame_2)
my_list <- setNames(my_list,paste0("data_frame_",1:2))
You can do this using assign
. Check out these links for reference.
Error in : target of assignment expands to non-language object
Create a variable name with "paste" in R?
assign(paste0("data_frame_",a), "some_data")