I have a data frame called totaldata that is 10,000 rows by about 9 columns. The data frame contains many zero entries which are important. If I type >totaldata it only prints out the first two columns. I expect (and want) it to print out all 9 columns. (I am actually "sinking" this to a text file, so imagine my surprise when the text file has only a few columns). I know totaldata contains all the data as summary(totaldata) lists what I expect (9 variables). Thanks for your help. [[alternative HTML version deleted]]
Can you show how you know the output has only two columns? My suspicion is that you are only seeing the `bottom' of the output, as in:> x <- as.data.frame(matrix(rnorm(45), 5, 9)) > xV1 V2 V3 V4 V5 V6 V7 1 -1.3241632 -0.9702919 -0.5070715 -0.01663753 -0.4867538 -0.557795429 0.03280373 2 -0.5320836 -0.1909115 -1.7211625 0.96653354 -0.9725586 -0.615651853 -0.94440277 3 1.0103191 -0.2025051 -0.3503634 0.79479308 0.1371226 0.001793848 0.20177179 4 -0.4493096 -0.4028332 0.5452380 -1.10063483 -0.5791613 -0.349573429 -0.15464095 5 1.7484486 0.1401273 1.7100899 0.31960320 1.2972502 -0.039784320 1.24036281 V8 V9 1 -0.7514973 0.07072891 2 -1.0099401 -0.02827683 3 -1.3194879 0.19499958 4 1.7867851 -0.29690245 5 -0.1055813 -0.33510362 Why not use write.table() or even write(), instead of sink()? Andy> From: Rishi Ganti > > I have a data frame called totaldata that is 10,000 rows by > about 9 columns. The > data frame contains many zero entries which are important. > If I type >totaldata > it only prints out the first two columns. I expect (and > want) it to print out all > 9 columns. (I am actually "sinking" this to a text file, so > imagine my surprise > when the text file has only a few columns). I know totaldata > contains all the data as > summary(totaldata) lists what I expect (9 variables). Thanks > for your help. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
Rishi Ganti wrote:> I have a data frame called totaldata that is 10,000 rows by about 9 columns.If "about 9" equals 2, the behaviour reported below is expected. > The> data frame contains many zero entries which are important. If I type >totaldata > it only prints out the first two columns. I expect (and want) it to print out all > 9 columns.Are you sure that R has not wrapped the data frame by printing the first few columns at first, and ended by printing the last 2 columns? This way the data fit into your window. You can set the width using options(), and get all columns at once.> (I am actually "sinking" this to a text file, so imagine my surprise > when the text file has only a few columns).Please consider to use write.table()! Uwe Ligges > I know totaldata contains all the data as> summary(totaldata) lists what I expect (9 variables). Thanks for your help. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Marc Schwartz
2004-Jun-10 16:30 UTC
[R] displaying a table in full vs. typing variable name
On Thu, 2004-06-10 at 11:26, Uwe Ligges wrote:> Rishi Ganti wrote: > > > I have a data frame called totaldata that is 10,000 rows by about 9 columns. > > If "about 9" equals 2, the behaviour reported below is expected.That is, of course, for sufficiently large values of "about"... ;-) Marc