table2office {export}R Documentation

Export statistical output to a table in Microsoft Office / LibreOffice format

Description

Export currently showing R stats object or stats object obj to a Microsoft Office / LibreOffice table

Usage

table2office(
  x = NULL,
  file = "Rtable",
  type = c("PPT", "DOC"),
  append = FALSE,
  digits = 2,
  digitspvals = NULL,
  trim.pval = 1e-16,
  width = NULL,
  height = NULL,
  offx = 1,
  offy = 1,
  font = ifelse(Sys.info()["sysname"] == "Windows", "Arial", "Helvetica")[[1]],
  pointsize = 12,
  add.rownames = FALSE
)

table2ppt(...)

table2doc(...)

Arguments

x

given R stats object to export; if set to NULL the output of the previous R command will be exported.

file

name of output file. The .pptx or .docx extension is added automatically.

type

desired output type - "PPT" for PowerPoint and "DOC" for Word.

append

logical value - if TRUE and type="PPT" or "DOC" it will append the table to the given file, where file can also be a given corporate. If append=FALSE any existing file will be overwritten.

digits

number of digits after the comma (for all numeric columns except p-values or degrees of freedom)

digitspvals

number of digits after the comma (for p-values only). The default is equal to digits.

trim.pval

a threshold below which the p-values are trimmed as "< trim.pval".

width

desired width of table in inches. If the given width exceeds the page or slide width, the table width becomes the page/slide width.

height

desired height of table in inches. If the given height exceeds the page or slide height, the table height becomes the page/slide height.

offx

x offset in inches to specify horizontal location of table (only for type=="PPT").

offy

y offset in inches to specify vertical location of table (only for type=="PPT").

font

desired font to use for output table; defaults to "Arial" on Windows systems and to "Helvetica" on other systems.

pointsize

desired font point size.

add.rownames

logical specifying whether or not to add row names.

...

Further arguments to be passed to table2office.

Details

Columns corresponding to degrees of freedom (with header "Df" or "df") are always given as integers. Objects that can be exported with table2office are all those supported by xtable and tidy. The function will first use xtable to format the data. If the data class is not supported by xtable the function will then use tidy. The data classes suported by xtable are:

The data classes suported by tidy are:

Value

flextable object

Functions

Author(s)

Tom Wenseleers, Christophe Vanderaa

See Also

table2tex, table2html, table2spreadsheet

Examples

# Create a file name
filen <- tempfile(pattern = "table_aov") # or 
# filen <- paste("YOUR_DIR/table_aov")

# Generate ANOVA output
fit=aov(yield ~ block + N * P + K, data = npk) # 'npk' dataset from base 'datasets'

# Save ANOVA table as a PPT
### Option 1: pass output as object
x=summary(fit)
if (interactive()) 
    table2ppt(x=x,file=filen, digits = 1, digitspvals = 3)
### Option 2: get output from console 
summary(fit)
if (interactive())
    table2ppt(x=x,file=filen, width=5, font="Times New Roman", pointsize=14, 
          digits=4, digitspvals=1, append=TRUE) # append table to previous slide

# Save ANOVA table as a DOC file
if (interactive())
    table2doc(x=x,file=filen, digits = 1, digitspvals = 3)
summary(fit)
if (interactive())
    table2doc(file=filen, width=3.5, font="Times New Roman", pointsize=14, 
          digits=4, digitspvals=1, append=TRUE) # append table at end of document

[Package export version 0.3.0 Index]