table2office | R Documentation |
Export currently showing R stats object or stats object obj to a Microsoft Office / LibreOffice table
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(...)
x |
given R stats object to export; if set to |
file |
name of output file. The .pptx or .docx extension is added automatically. |
type |
desired output type - |
append |
logical value - if |
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 |
trim.pval |
a threshold below which the p-values are trimmed as
"< |
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 |
offy |
y offset in inches to specify vertical location of table (only for |
font |
desired font to use for output table; defaults to |
pointsize |
desired font point size. |
add.rownames |
logical specifying whether or not to add row names. |
... |
Further arguments to be passed to |
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:
anova
aov
aovlist
data.frame
glm
gmsar
lagImpact
lm
matrix
prcomp
sarlm
sarlm.pred
spautolm
sphet
splm
stsls
summary.aov
summary.aovlist
summary.glm
summary.gmsar
summary.lm
summary.prcomp
summary.sarlm
summary.spautolm
summary.sphet
summary.splm
summary.stsls
table
ts
zoo
The data classes suported by tidy
are:
aareg
acf
Arima
betareg
biglm
binDesign
binWidth
brmsfit
btergm
cch
character
cld
coeftest
confint.glht
cv.glmnet
default
density
dgCMatrix
dgTMatrix
dist
emmGrid
ergm
felm
fitdistr
ftable
gam
Gam
gamlss
geeglm
glht
glmnet
glmRob
gmm
htest
ivreg
kappa
kde
kmeans
Line
Lines
list
lme
lmodel2
lmRob
logical
lsmobj
manova
map
Mclust
merMod
mle2
muhaz
multinom
nlrq
nls
NULL
numeric
orcutt
pairwise.htest
plm
poLCA
Polygon
Polygons
power.htest
pyears
rcorr
ref.grid
ridgelm
rjags
roc
rowwise_df
rq
rqs
sparseMatrix
SpatialLinesDataFrame
SpatialPolygons
SpatialPolygonsDataFrame
spec
speedlm
stanfit
stanreg
summary.glht
summaryDefault
survdiff
survexp
survfit
survreg
tbl_df
TukeyHSD
flextable
object
table2ppt()
: Export statistical output to a table in a Microsoft Office PowerPoint/ LibreOffice Impress presentation
table2doc()
: Export statistical output to a table in a Microsoft Office Word/ LibreOffice Writer document
Tom Wenseleers, Christophe Vanderaa
table2tex
, table2html
, table2spreadsheet
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.