Evaluate dataframe$column expression stored as a string value

后端 未结 2 590
轻奢々
轻奢々 2021-01-28 22:11

Can a string of the form below be evaluated so that it is equivalent to the same \"literal\" expression?

Example data and code:

df.name = data.frame(col1         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-28 22:29

    You are almost there:

    > eval(parse(text = var1))
    [1] "D"
    

    Because parse expecting file by default, you need to specify the text parameter.

提交回复
热议问题