ReplaceFromTable: ReplaceFromTable

Description Usage Arguments Details Value See Also Examples

View source: R/PreambleAdjustment.R

Description

Given a 'LaTeX' file represented as a character vecotr with x, it replaces from a table the commands given by commandNames. for the values found on the table.

\newcommand{\commandName[i]}{table[tableRow, columnName[i]]}.

Usage

1
ReplaceFromTable(x, table, tableRow, columnNames, commandNames)

Arguments

x

A character vector, each element is suppose to represent a line

table

Data frame from which to extract the information

tableRow

Integer, row of the table to be used

columnNames

Character vector with the names of the columns to be used

commandNames

Character vector with the same length as columnNames. Contains the names of the 'LaTeX' commands to be replaced.

Details

To do the replacement for each item, it uses the function ReplacePreambleCommand. See the details in that function for more information.

Value

A character vector, representing the text x, where all instances of \newcommand\commandNames[i]{<random text>} have been replaced with \newcommand\commandNames[i]{table[tableRow, columnName[i]}.

See Also

Other Preamble adjustment: ReplacePreambleCommand

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
custom_preambles <- list()
for (i in 1:nrow(TexExamRandomizer::testclass)) {
    custom_preambles <-
        c(
            custom_preambles,
            list(
                TexExamRandomizer::ReplaceFromTable(
                    TexExamRandomizer::testdoc$preamble,
                    table = TexExamRandomizer::testclass,
                    tableRow = i,
                    columnNames = c("Class", "Roll.Number", "Nickname"),
                    commandNames = c("class", "rollnumber", "nickname")
                )
            )

        )

}

TexExamRandomizer documentation built on May 2, 2019, 3:18 a.m.