DescTools (version 0.99.18)

ToWrd: Send Objects to Word

Description

Send objects like tables, ftables, lm tables, TOnes or just simple texts to a MS-Word document.

Usage

ToWrd(x, font = NULL, ..., wrd = DescToolsOptions("lastWord"))
"ToWrd"(x, font = NULL, main = NULL, ..., wrd = DescToolsOptions("lastWord"))
"ToWrd"(x, font = NULL, main = NULL, align = NULL, tablestyle = NULL, autofit = TRUE, row.names = FALSE, col.names = TRUE, ..., wrd = DescToolsOptions("lastWord"))
"ToWrd"(x, font = NULL, main = NULL, align = NULL, method = "compact", ..., wrd = DescToolsOptions("lastWord"))
"ToWrd"(x, font = NULL, para = NULL, main = NULL, align = NULL, autofit = TRUE, ..., wrd = DescToolsOptions("lastWord"))
"ToWrd"(x, font = NULL, ..., wrd = DescToolsOptions("lastWord"))
"ToWrd"(x, font = NULL, para = NULL, style = NULL, ..., wrd = DescToolsOptions("lastWord"))
"ToWrd"(x, font = NULL, ..., wrd = DescToolsOptions("lastWord"))

Arguments

x
the object to be transferred to Word.

font
the font to be used to the output. This should be defined as a list containing fontname, fontsize, bold and italic flags: list(name="Arial", size=10, bold=FALSE, italic=TRUE).

para
list containing paragraph format properties to be applied to the inserted text. For right align the paragraph one can set: list(alignment="r", LineBefore=0.5). See details for the full set of properties.
main
a caption for a table. This will be inserted by InsertCaption in Word and can be listed afterwards in a specific index. Default is NULL, which will insert nothing. Ignored if x is not a table.

align
character vector giving the alignment of the table columns. "l" means left, "r" right and "c" center alignement. The code will be recyled to the length of thenumber of columns.

method
string specifying how the "ftable" object is formatted (and printed if used as in write.ftable() or the print method). Can be abbreviated. Available methods are (see the examples):

autofit
logical, defining if the columns of table should be fitted to the length of their content.

row.names
logical, defining whether the row.names should be included in the output. Default is FALSE.

col.names
logical, defining whether the col.names should be included in the output. Default is TRUE.

tablestyle
either the name of a defined Word tablestyle or its index.

style
character, name of a style to be applied to the inserted text.
...
further arguments to be passed to or from methods.

wrd
the pointer to a word instance. Can be a new one, created by GetNewWrd() or an existing one, created by GetCurrWrd(). Default is the last created pointer stored in DescToolsOptions("lastWord").

Value

Details

The paragraph format can be defined by means of these properties: LeftIndent, RightIndent, SpaceBefore, SpaceBeforeAuto, SpaceAfter, SpaceAfterAuto, LineSpacingRule, Alignment, WidowControl, KeepWithNext, KeepTogether, PageBreakBefore, NoLineNumber, Hyphenation, FirstLineIndent, OutlineLevel, CharacterUnitLeftIndent, CharacterUnitRightIndent, CharacterUnitFirstLineIndent, LineUnitBefore, LineUnitAfter, MirrorIndents.

See Also

GetNewWrd

Examples

Run this code
## Not run: 
# # run that by copy to console
# #
# t1 <- TOne(x = d.pizza[, c("temperature","delivery_min","driver","wine_ordered")],
#            grp=d.pizza$wine_delivered)
# 
# wrd <- GetNewWrd()
# ToWrd(t1, font=list(name="Algerian"), wrd=wrd)
# 
# 
# tab <- table(d.pizza$driver, d.pizza$area)
# 
# tab <- table(d.pizza$driver, d.pizza$area)
# ToWrd(tab, font = list(size=15, name="Arial"), row.names = TRUE, col.names = TRUE,
#       main= "my Title", wrd=wrd)
# ToWrd(tab, font = list(size=10, name="Arial narrow"),
#       row.names = TRUE, col.names=FALSE, wrd=wrd)
# ToWrd(tab, font = list(size=15, name="Arial"), align="r",
#       row.names = FALSE, col.names=TRUE, wrd=wrd)
# ToWrd(tab, font = list(size=15, name="Arial"),
#       row.names = FALSE, col.names=FALSE, wrd=wrd)
# 
# ToWrd(tab, tablestyle = "Mittlere Schattierung 2 - Akzent 4",
#       row.names=TRUE, col.names=TRUE, wrd=wrd)
# 
# ToWrd(Format(tab, big.mark = "'", digits=0), wrd=wrd)
# 
# zz <- ToWrd(Format(tab, big.mark = "'", digits=0), wrd=wrd)
# zz$Rows(1)$Select()
# WrdFont(wrd = wrd) <- list(name="Algerian", size=14, bold=TRUE)
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace