Convert data frame row to column names

后端 未结 2 610
走了就别回头了
走了就别回头了 2021-01-14 02:29

Is there a quick way (part of the tidyverse API perhaps) to turn a row into column names for a data.frame or tibble, somewhat similar

2条回答
  •  天命终不由人
    2021-01-14 02:39

    Well, you can simply: colnames(df) <- as.character(df[1, ])

    And if you want to remove this first row: df <- df[-1,]

提交回复
热议问题