[R] How to illustrate data of a csv file as table (xtable?)

David Winsemius dwinsemius at comcast.net
Sat May 24 17:53:20 CEST 2014


On May 23, 2014, at 4:49 PM, Duncan Murdoch wrote:

> On 23/05/2014, 6:31 PM, Verena Weinbir wrote:
>> Hello!
>> 
>> I'd like to illustrate the data of an csv file as a nice table and copy it
>> into my word-sheet. Currently, I am trying this with the xtable () function
>> (latex output).
> 
> I'm not sure what you mean by copying it into your word-sheet, but latex has a lot of flexibility in formatting tables.  See the http://en.wikibooks.org/wiki/LaTeX/Tables page for a description.  It might be that you can get xtables to produce output suitable for that; you can certainly get the tables package to do it.  (The vignette gives an example of a multi-page table, but doesn't include any rotated ones.)
> 

I am also uncertain about the meaning of "word-sheet". If it means an Excel worksheet, then the strategy I use is to copy the output of the table()-function to an Excel worksheet and then use the text-to-columns choice off the Data-menu.

In preparation for multi-page tables I simply use:

 options(width=250)

The advantage in Excel is the option to use conditional formatting, for instance taking a a large set of cross-tabulated estimates of mortality risk and highlight the higher estimates that have a sufficient number of events to be credible and grey out the estimates based on small numbers of events. It's not my preferred method of analysis but it gets around the unfortuante fact that actuaries are  not accustomed to see output from regression models using spline transformation of predictors. I'm sometimes surprised at the patterns this displays. It is a "non-parametric" method of displaying multi-dimensional relationships. I suspect there are R packages that I have not yet explored that might have similar or superior power. The 'vcd' package is one that has considerable power.


> Duncan Murdoch
> 
>> 
>> Example Code:
>> 
>> dfchar <- data.frame(Author = dat$author, Year = dat$year, Age = dat$age)
>> xtable(dfchar)
>> 
>> Now, since there are some more variables and many more data sets I have to
>> include, I need to change the table orientation to landscape*. *The size of
>> the table should run over several pages.
>> 
>> Does anyone know how to implement this with the xtable () function or can
>> provide me with an alternative function?
>> 
>> Thank you very much in advance!
>> 
>> Verena
>> 
>> 	[[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list