Add a multiple-choice or single-choice question to a dataframe, validating and/or transforming inputs.
Usage
add_question(
question,
image = NA,
explanation = NA,
correct = NA,
incorrect = NA,
keywords = NA,
df = NA
)Arguments
- question
Question text
- image
Image filename (optional)
- explanation
Explanation for the correct answer (optional)
- correct
Vector of possible correct answers
- incorrect
Vector of possible incorrect answers
- keywords
Vector of strings to insert into the question text
- df
Dataframe to add question to
Value
The provided dataframe df, with an additional row. If a dataframe
is not provided, a new one is created.
Examples
df <- examling::build_question_df()
df <- add_question(
question = "What color is a male cardinal?",
correct = c("Red"),
incorrect = c("Green", "Blue"),
df = df
)
df
#> question image correct incorrect explanation
#> 1 What color is a male cardinal? NA Red Green, Blue NA