pons 0.0.0.932
New features
- Interface between R and Microsoft Word and Excel via the Component Object Model, supplying the Office layer of the DescToolsX package suite. Windows only; requires a local Office installation and
RDCOMClient. -
toWrd()writes content of the common R classes into a running Word document, with control over font, paragraph format, style template and bullet lists. -
toWrd()methods fordata.frame,matrix,table,TOneandTModwrite formatted tables (header rules, decimal-tab alignment, paragraph spacing);wrdSymbolMap()replaces-,=>,<=etc. by their typographic characters. -
labelsfor theTMod,matrixandtablemethods oftoWrd(): a named character vector or a function relabels coefficients, statistics or row names. -
toWrd(..., bookmark = "name")encloses the output of any method in a Word bookmark; an existing bookmark is replaced in place, so re-running a script updates the report.bookmark = TRUEgenerates a name. The RStudio addins for text bookmarks use this mechanism. -
font = "fix"writes text in the paragraph style “R Output” (Consolas 10 pt, line spacing 1.25, no space before/after, no spell checking), created if the document has no such style, so it can be designed in Word or a template. Name and defaults:options(pons.fixstyle = ). Tables use its font. Formerly Courier New 8 pt was set directly. - Plots for Word:
toWrd()inserts captured plotting code (wrdPlot()), recorded base graphics (recordPlot()),ggplotandtrellisobjects as pictures of a given size in cm (png, emf or svg), aligned and bookmarkable (generated names start withbmp). The RStudio plot bookmark addins use this instead of the formerToWrdPlot(). - Bookmark handling makes reports updatable in place:
wrdAddBookmark(),wrdBookmark(),renameBookmark(),wrdDeleteBookmark(),bookmarkList()andwrdGoto().replaceBookmarkText()restores the bookmark that Word discards when the underlying text is replaced. -
xlGetRange()andxlParseRange()read an Excel selection - including disjoint multi-area selections - into a data frame, matrix, list or table, with header handling and per-column type detection. -
xlImport()wraps the above in a Tcl/Tk dialog and either assigns the result or inserts constructive R code at the editor cursor. -
xlView()opens data frames, matrices, tables, vectors and nested lists in Excel, with methods forlmandglmthat write the coefficient table with optional confidence intervals, ANOVA and fitted values.
Documentation
- New vignette “Reporting to Word with pons”: a short analysis of the
infertdata reported to Word, demonstrating alltoWrd()options, plots and updatable bookmarks.
Bug fixes
autofitof the table methods:"window"(default, as before: content, then window width),"content"(orTRUE, the table only as wide as its content) or"none"(orFALSE). FormerlyTRUEalso stretched the table to the window width.Default alignment: only columns holding numbers are aligned at the decimal point, text columns left; text in decimal columns had been pushed to the tab stop and wrapped.
decpos = NAestimates the position likeNULL.Printed output (
toWrd.default(), e.g.summary()) now ends with a paragraph mark; the following output ran on in the same paragraph. Text gets one withnewpara = TRUE.Tables written one after the other were merged by Word into one table (and setting the alignment of its columns then failed with a COM exception). A table is now followed by an empty paragraph (
newpara = TRUE).Numbers are formatted consistently with
pharos::fm():digits(number of decimals) andfmt(format code such as"%", or aStyle) for the matrix and table methods and, applied to the numeric columns, for the data.frame method. Formerlydigitsmeant significant digits (format()).font = "fix"failed for all table methods; fonts are now resolved centrally and checked before anything is written to Word.summary()of a vector (classsummaryDefault, inheriting fromtable) was written as a table; it is written as printed text again.The RStudio addin “To Word” pointed to the non-existent
ToWrd(); it now calls the newxtoWrd().xlParseRange()failed on multi-area selections (internal calls used the non-existent argumentas =instead ofoutput =).wrdSymbolMap()was broken in non-UTF-8 locales: non-ASCII regex patterns given as argument tags were translated to<U+2264>text. The minus rule now also applies after a non-breaking space (N = -3).The internal output capture failed on literal constants (“bad argument”).
Internal
- Test suite for all COM-free parts (symbol map, table preparation, the
toWrd()table methods with a mocked Word layer,xlParseRange(), type conversion, deparser, output capture).
