tests/testthat/helper.R

# Create surveydata object


test_survey <- local({
  dat <- data.frame(
    id   = 1:4,
    Q1   = c("Yes", "No", "Yes", "Yes"),
    Q4_1 = c(1, 2, 1, 2), 
    Q4_2 = c(3, 4, 4, 3), 
    Q4_3 = c(5, 5, 6, 6), 
    Q10 = factor(c("Male", "Female", "Female", "Male")),
    crossbreak  = c("A", "A", "B", "B"), 
    weight      = c(0.9, 1.1, 0.8, 1.2)
  )
  
  varlabels(dat) <- c(
    "RespID",
    "Question 1", 
    "Question 4: red", "Question 4: green", "Question 4: blue", 
    "Question 10",
    "crossbreak",
    "weight"
  )
  
  as.surveydata(dat, renameVarlabels=TRUE)
})

Try the surveydata package in your browser

Any scripts or data that you put into this service are public.

surveydata documentation built on July 20, 2017, 1:04 a.m.