# create/edit template HTML file
# should have placeholders of the form `${varName}` for variable values
temp <- system.file("templates/htmlquestion2.xml", package = "MTurkR")
readLines(temp)
# create/load data.frame of template variable values
a <- data.frame(hittitle = c("HIT title 1","HIT title 2","HIT title 3"),
                hitvariable = c("HIT text 1","HIT text 2","HIT text 3"), 
                stringsAsFactors=FALSE)
# create HITs from template and data.frame values
temps <- GenerateHITsFromTemplate(template = temp, input = a)
# create HITs from template
hittype1 <- RegisterHITType(title = "2 Question Survey",
              description = "Complete a 2-question survey",
              reward = ".20", 
              duration = seconds(hours=1), 
              keywords = "survey, questionnaire, politics")
hits <- lapply(temps, function(x) {
    CreateHIT(hit.type = hittype1$HITTypeId, 
              expiration = seconds(days = 1),
              assignments = 2,
              question = GenerateHTMLQuestion(x)$string)
})
# cleanup
ExpireHIT(hit.type = hittype1$HITTypeId)
DisposeHIT(hit.type = hittype1$HITTypeId)Run the code above in your browser using DataLab