Description Usage Arguments Details Examples
Insert a paragraph of text into a Docx object
.
1 2 | ## S4 method for signature 'Docx, character, character, list, list, character'
addParagraph(x, value, stylename, replacements, replacement.styles, bookmark)
|
x |
the |
value |
character vector containing texts to add. |
stylename |
value of the named style in the docx document. |
replacements |
optional, a named list whose elements define replacements values. |
replacement.styles |
optional, a named list specifying formats to apply to replacements. |
bookmark |
a character value ; id of the Word bookmark to replace by the table. optional |
value
: text(s) to add, a character vector.
Example : value="Hello world"
If replacements have to be done, keywords that identify text to be replaced must be contained into square brackets [].
Example : value="At the [ALPHA] significance level, one [DECISION] the null hypothesis."
replacements
: a name list, names are keywords (of the value
, contained into square brackets) and values are replacements values
Example : value = "[animal] eats [food]."
, replacements =
list( animal = "donkey" , food = "grass" )
replacement.styles
: a name list, names are keywords (of the value
, contained into square brackets) and values are replacements styles values
Example : value = "[animal] eats [food]."
, replacements =
list( animal = "donkey" , food = "grass" )
, replacement.styles =
list( animal= textProperties(color="red" ) , food= textProperties(color="blue" ) )
bookmark
: a character vector specifying bookmark id to replace by the table.
If provided, table will replace the paragraph that contains the bookmark.
If not provided, table will be added at the end of the document.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | doc <- new("Docx", title = "My example" )
doc <- addParagraph( doc, value = "Hello", stylename = "Normal")
x = c( "[animal] eat [food].", "tigers eat [animal]." )
repl.styles = list(
animal= textProperties( font.size = 12, font.family="Courier New", color="red" )
, food= textProperties( font.size = 12, font.family="Courier New", color="blue" )
)
repl = list( animal = "buffalos" , food = "grass" )
doc <- addParagraph( doc, value = x, stylename = "Normal"
, replacements = repl
, replacement.styles = repl.styles
)
doc <- addParagraph( doc, value = letters[1:10], stylename = "BulletList")
## Not run:
writeDoc( doc, "Paragraph_example.docx" )
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.