startrtf: Create an RTF Document

View source: R/startrtf.R

startrtfR Documentation

Create an RTF Document

Description

Create an rtf (rich text format) document.

Usage

startrtf(
  file = NULL,
  dir = getwd(),
  width = 8.5,
  height = 11,
  omi = c(1, 1, 1, 1),
  quiet = FALSE
)

Arguments

file

Character scalar name of document, default "RGeneratedDocument" with Sys.Date() suffix.

dir

Character scalar name of directory where document should be stored, default getwd().

width

Numeric scalar width of document page in inches, default 8.5.

height

Numeric scalar height of document page in inches, default 11.

omi

Numeric vector, length 4, width of document page margins in inches (bottom, left, top, right), default c(1, 1, 1, 1).

quiet

Logical scalar indicating if name of new rtf document should be printed to command line, default FALSE.

Details

The rtf file may be written to until the endrtf() function is run. If you assign your rtf file to an object called doc, you can use the default settings in other GLFC rtf functions.

Value

An rtf file is created in the specified directory. An object of class rtf is created. This object is referred to in other functions to write to the file. In addition, two numeric vectors of length 1, tabcount and figcount, are written to the working directory to keep track of the number of tables and figures written to the rtf document, and label the captions accordingly.

See Also

heading, para, tabl, figu, figbig, endrtf, RTF.

Examples

## Not run: 
# open a Word-friendly rtf file
today <- Sys.Date()
doc <- startrtf(file=paste("Example", today))
# add headings
heading("Title")
heading(paste("Author", today, sep=" - "), 2)
# add a paragraph
para("This is how write a paragraph.")
# reference a table
para("This is how you reference a table (Table ", GLFCenv$tabcount, ").")
# add the table
tab <- matrix(sample(20), ncol=5,
 dimnames=list(paste("Row", 1:4), paste("Column", 1:5)))
tabl("A silly table.")
# reference a figure
para("And this is how you reference a figure (Figure ",
 GLFCenv$figcount, ").")
# add the figure
fig <- function() {
  par(mar=c(4, 4, 1, 1))
  plot(1:10, 1:10, xlab="X", ylab="Y")
}
figu("A silly plot.", h=4, w=4)
# save the rtf file
endrtf()

## End(Not run)

JVAdams/GLFC documentation built on Jan. 5, 2023, 12:59 a.m.