Learn R Programming

MTurkR (version 0.5.1)

GenerateHITsFromTemplate: Generate HITs from a Template

Description

Generate individual HIT .html files from a local .html HIT template file, in the same fashion as the MTurk Requester User Interface (RUI). This function facilitates the use of ExternalQuestion data structures.

Usage

GenerateHITsFromTemplate(template, input, filenames = NULL, write.files = FALSE)

Arguments

template
A file handle for an .html HIT template saved in the working directory.
input
A dataframe containing one row for each HIT to be created and columns named identically to the placeholders in the HIT template file. Operation will fail if variable names do not correspond.
filenames
An optional list of filenames for the HITs to be created. Must be equal to the number of rows in input.
write.files
A logical specifying whether HIT .html files should be created and stored in the working directory. Or, alternatively, whether HITs should be returned as character vectors in a list.

Value

  • If write.files=FALSE, a list containing a character string for each HIT generated from the template. Otherwise, one or more HITs in the form of .html files stored in the working directory, with filenames specified by the filenames option or, if filenames=NULL of the form NewHIT1.html, NewHIT2.html, etc.

Details

Generate HITs from a HIT template (containing placeholders for input data). The tool provides functionality analogous to the MTurk RUI HIT template and can be performed on .html files generated therein. hitsfromtemplate() is an alias.

References

http://docs.amazonwebservices.com/AWSMechTurk/latest/RequesterUI/CreatingaHITTemplate.html{API Reference: Operation} http://docs.amazonwebservices.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_ExternalQuestionArticle.html{API Reference: ExternalQuestion Data Strucure}

Examples

Run this code
a <- data.frame(c("HIT text 1","HIT text 2","HIT text 3"))
names(a) <- "hitvariable"
GenerateHITsFromTemplate("mynewhit.html",input=a,write.files=TRUE)

Run the code above in your browser using DataLab