In R, I am trying to get input from a user to create the name of a new data frame. eg
number <- readline(prompt = "what is your number:")
Which creates a character string with one entry, eg number: "4"
Now i want to create a dataframe named after the character inputted, and subset some other information based on that number from another table, for example:
number_4 <- subset(df, df$NO=="4")
As i might be doing hundreds of these i do not want to have to manually name each dataframe, is there a way to use the character to name a dataframe?
我们可以使用assign
功能
assign(paste0("number_", number), subset(df, NO == number))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.