printing - Removing display of R row names from data frame -
printing - Removing display of R row names from data frame -
i creating dataframe using code:
df <- data.frame(dbgetquery(con, paste('select * test'))) which results in this:
uid buildingcode accesstime 1 123456 build-1 2014-06-16 07:00:00 2 364952 build-2 2014-06-15 08:00:00 3 95865 build-1 2014-06-06 09:50:00 i trying remove row names (1, 2, 3, etc) suggested here using code:
rownames(df) <- null but when print out df still displays row names. there way not include row names when creating info frame? found suggestion row.name = false when tried got errors (i might have placed in wrong place).
edit: want convert dateframe html table , don't want row name nowadays in table.
you have removed rownames. print.data.frame method shows row numbers if no rownames present.
df1 <- data.frame(values = rnorm(3), grouping = letters[1:3], row.names = paste0("rowname", 1:3)) print(df1) # values grouping #rowname1 -1.469809 #rowname2 -1.164943 b #rowname3 0.899430 c rownames(df1) <- null print(df1) # values grouping #1 -1.469809 #2 -1.164943 b #3 0.899430 c you can suppress printing rownames , numbers in print.data.frame argument row.names.
print(df2, row.names = false) # values grouping # -1.4345829 d # 0.2182768 e # -0.2855440 f edit written in comments, want covert html. xtable , print.xtable docs can see argument include.rownames trick.
library("xtable") print(xtable(df1), type="html", include.rownames = false) #<!-- html table generated in r 3.1.0 xtable 1.7-3 bundle --> #<!-- thu jun 26 12:50:17 2014 --> #<table border=1> #<tr> <th> values </th> <th> grouping </th> </tr> #<tr> <td align="right"> -0.34 </td> <td> </td> </tr> #<tr> <td align="right"> -1.04 </td> <td> b </td> </tr> #<tr> <td align="right"> -0.48 </td> <td> c </td> </tr> #</table> r printing data.frame output-formatting rowname
Comments
Post a Comment