Removing display of row names from data frame

后端 未结 5 1675
遥遥无期
遥遥无期 2020-11-27 16:15

I am creating a dataframe using this code:

df <- data.frame(dbGetQuery(con, paste(\'select * from test\')))

Which results in this:

5条回答
  •  情歌与酒
    2020-11-27 16:34

    Yes I know it is over half a year later and a tad late, BUT

    row.names(df) <- NULL
    

    does work. For me at least :-)

    And if you have important information in row.names like dates for example, what I do is just :

    df$Dates <- as.Date(row.names(df))
    

    This will add a new column on the end but if you want it at the beginning of your data frame

    df <- df[,c(7,1,2,3,4,5,6,...)]
    

    Hope this helps those from Google :)

提交回复
热议问题