Using variable value as column name in data.frame or cbind

后端 未结 4 1649
一整个雨季
一整个雨季 2020-12-06 06:15

Is there a way in R to have a variable evaluated as a column name when creating a data frame (or in similar situations like using cbind)?

For example



        
4条回答
  •  無奈伤痛
    2020-12-06 06:56

    > d <- setNames( data.frame(a=1:10), a)
    > d
       mycol
    1      1
    2      2
    3      3
    4      4
    5      5
    6      6
    7      7
    8      8
    9      9
    10    10
    

提交回复
热议问题