storeAnswer function

Update Answer to Single Item

Update Answer to Single Item

Stores answer to item kk to the Cat object's answers slot.

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

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.

Returns

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.

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

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

Author(s)

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

  • Maintainer: Erin Rossiter
  • License: GPL-3
  • Last published: 2022-12-03

Useful links