ReplaceFromTable {TexExamRandomizer}R Documentation

ReplaceFromTable

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

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


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")
                )
            )

        )

}

[Package TexExamRandomizer version 1.2.7 Index]