I would like to create data frames from a FOR-LOOP in R.
Basically, I would like to do something like this:
for (i in 1:3) { x"i"= 1+i}
In this case, I would like to get 3 dataframes:
Is there a way to do this in R?
for (i in 1:3) {
assign(paste0("x", i), i + 1)
}
This will create objects x1, x2, and x3 with the values of i + 1, i.e., 2-4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With