use first row data as column names in r

后端 未结 8 1624
遇见更好的自我
遇见更好的自我 2020-12-05 09:58

I have a dirty dataset that I could not read it with header = T. After I read and clean it, I would like to use the now first row data as the column name. I tri

8条回答
  •  不知归路
    2020-12-05 10:35

    Take a step back, when you read your data use skip=1 in read.table to miss out the first line entirely. This should make life a bit easier when you're cleaning data, particularly for data type. This is key as your problem stems from your data being encoded as factor.

    You can then read in your column names separately with nrows=1 in read.table.

提交回复
热议问题