[R] how to print a data.frame without row.names
Heinz Tuechler
tuechler at gmx.at
Tue Aug 2 17:46:07 CEST 2005
At 16:05 02.08.2005 +0200, Romain Francois wrote:
>Le 02.08.2005 15:45, Heinz Tuechler a écrit :
>
>>Dear All,
>>is there a simple way to print a data.frame without its row.names?
>>
>>example:
>>datum <- as.Date(c("2004-01-01", "2004-01-06", "2004-04-12"))
>>content <- c('Neujahr', 'Hl 3 K.', 'Ostern')
>>df1 <- data.frame(datum, content)
>>print(df1)
>>
>> datum content
>>1 2004-01-01 Neujahr
>>2 2004-01-06 Hl 3 K.
>>3 2004-04-12 Ostern
>>
>>Can I get this "table" without 1, 2, 3 ?
>>
>>
>See write.table and its row.names argument
>
>R> write.table(df1, row.names=FALSE)
>
>Romain
>
write.table(df1, row.names=FALSE, quote=FALSE)
datum content
2004-01-01 Neujahr
2004-01-06 Hl 3 K.
2004-04-12 Ostern
I tried this, but then the column headers and column contents are not aligned.
If you expand the example, you see clearly the difference.
datum <- as.Date(c("2004-01-01", "2004-01-06", "2004-04-12"))
content <- c('Neujahr', 'Hl 3 K.', 'Ostern')
number <- c(1, 6, 110)
string <- c('a', 'bbbb', 'c')
df1 <- data.frame(datum, content, number, string)
print(df1)
datum content number string
1 2004-01-01 Neujahr 1 a
2 2004-01-06 Hl 3 K. 6 bbbb
3 2004-04-12 Ostern 110 c
write.table(df1, row.names=FALSE, quote=FALSE)
datum content number string
2004-01-01 Neujahr 1 a
2004-01-06 Hl 3 K. 6 bbbb
2004-04-12 Ostern 110 c
Maybe I missed a function like print.xtable with type="ascii". It seems
that it has to be done with cat.
Thank you
Heinz
>--
>visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
>~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
>~~~~~~ Romain FRANCOIS - http://addictedtor.free.fr ~~~~~~
>~~~~ Etudiant ISUP - CS3 - Industrie et Services ~~~~
>~~ http://www.isup.cicrp.jussieu.fr/ ~~
>~~~~ Stagiaire INRIA Futurs - Equipe SELECT ~~~~
>~~~~~~ http://www.inria.fr/recherche/equipes/select.fr.html ~~~~~~
>~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
>
>
More information about the R-help
mailing list