How do you delete the header in a dataframe?

前端 未结 7 667
故里飘歌
故里飘歌 2021-01-04 19:40

I want to delete the header from a dataframe that I have. I read in the data from a csv file then I transposed it, but it created a new header that is the name of the file a

7条回答
  •  醉话见心
    2021-01-04 20:18

    If you really, really, really don't like column names, you may convert your data frame to a matrix (keeping possible coercion of variables of different class in mind), and then remove the dimnames.

    dd <- data.frame(x1 = 1:5, x2 = 11:15)
    mm1 <- as.matrix(dd)
    mm2 <- matrix(mm1, ncol = ncol(dd), dimnames = NULL)
    

    I add my previous comment here as well:
    ?data.frame: "The column names should be non-empty, and attempts to use empty names will have unsupported results.".

提交回复
热议问题