Getting strings recognized as variable names in R

后端 未结 6 1771
我在风中等你
我在风中等你 2020-11-28 18:39

Related: Strings as variable references in R
Possibly related: Concatenate expressions to subset a dataframe


I\'ve simplified the question per the comment

6条回答
  •  清酒与你
    2020-11-28 19:03

    If you want to use a string as a variable name, you can use assign:

    var1="string_name"
    
    assign(var1, c(5,4,5,6,7))
    
    string_name 
    
    [1] 5 4 5 6 7
    

提交回复
热议问题