How to name variables on the fly?

前端 未结 6 1653
执念已碎
执念已碎 2020-11-22 10:11

Is it possible to create new variable names on the fly?

I\'d like to read data frames from a list into new variables with numbers at the end. Something like orca1, o

6条回答
  •  悲&欢浪女
    2020-11-22 10:16

    It seems to me that you might be better off with a list rather than using orca1, orca2, etc, ... then it would be orca[1], orca[2], ...

    Usually you're making a list of variables differentiated by nothing but a number because that number would be a convenient way to access them later.

    orca <- list()
    orca[1] <- "Hi"
    orca[2] <- 59
    

    Otherwise, assign is just what you want.

提交回复
热议问题