Learn R Programming

catSurv (version 1.5.0)

storeAnswer: Update Answer to Single Item

Description

Stores answer to item \(k\) to the Cat object's answers slot.

Usage

# S4 method for Cat
storeAnswer(catObj, item, answer, returnJSON = FALSE)

# S4 method for character storeAnswer(catObj, item, answer, returnJSON = FALSE)

Value

The function storeAnswer returns an updated object of class Cat with the answers slot reflecting the newly stored answer to the indicated item. All previously stored answers remain the same, and all unanswered questions remain NA.

Arguments

catObj

An object of class Cat or class json.

item

An integer indicating the index of the question item

answer

The answer to the item to be updated

returnJSON

Boolean indicating whether the updated Cat object should be returned as a JSON object. Defaults to FALSE.

Author

Haley Acevedo, Ryden Butler, Josh W. Cutler, Matt Malis, Jacob M. Montgomery, Tom Wilkinson, Erin Rossiter, Min Hee Seo, Alex Weil

Details

The function storeAnswer updates the Cat object, but the updated object must be assigned to an object for the changes to be stored. See Examples.

Examples

Run this code
## Loading ltm Cat object
data(ltm_cat)

## Printing current answers slot
getAnswers(ltm_cat)

## Storing answer of 0 to item 1
ltm_cat <- storeAnswer(ltm_cat, item = 1, answer = 0)

## Now object reflects answer to item 1
getAnswers(ltm_cat)


Run the code above in your browser using DataLab