在 R 中使用 Mturkr 包创建 HIT 时获取 HIT 状态

Obtaining HIT Status while Creating HIT using Mturkr Package in R

    library("MTurkR")
    credentials(c("EXAMPLEAWSKEY","EXAMPLEAWSSCERETKEY"))
    AccountBalance()
    #Fetching AccountBalance=[=10=].00

    # First set qualifications
    # ListQualificationTypes() to see different qual types
    qualReqs = paste(

        # Set Location to US only
        GenerateQualificationRequirement(
            "Location","==","US"),

        sep="" )

    # Create new batch of hits:
    newHIT = CreateHIT(

        # layoutid in sandbox:
        hitlayoutid="EXAMPLEHITLAYOUTID",
        sandbox=T,
        annotation = "HET Experiment with Pre-Screen",
        assignments = "1200",
        title="Rate this hypothetical representative",
        description="It's easy, just rate this
            hypothetical representative on how well
            she delivers funds to his district",
        reward=".50",
        duration=seconds(hours=4),
        expiration=seconds(days=7),
        keywords="survey, question, answers, research,
                politics, opinion",
        auto.approval.delay=seconds(days=15),
        qual.reqs=qualReqs
    )

    # Get HITId (record result below)
    newHIT$HITId

    HITStatus(hit="EXAMPLEHITID")
    #not able to fetch HIT STATUS.
    #I Can see HIT been Created in Worker Sandbox, But after submitting the   by the worker I am not able to fetch anything. 

review = GetAssignments(hit="Example HITID",
    status="Submitted", return.all=T)

我收到以下错误:

Error (AWS.MechanicalTurk.HITDoesNotExist): Hit 3IV1AEQ4DRV9ICWQ5F0YS4QBNVOJ85 does not exist. (1444808078544)

# Error in while (request$total > runningtotal) { : # missing value where TRUE/FALSE needed

尽管(第二条)错误消息的信息量不多,但实际上这一个非常简单。您已经在沙盒中创建了一个 HIT,但您正试图在实时服务器上检查它的状态,而它并不存在。

您可以通过将 sandbox = TRUE(或 sandbox = FALSE)参数传递给每个函数来解决此问题,并在所有代码中始终如一地执行此操作。更简单的替代方法是指定一个全局选项:

options(MTurkR.sandbox = TRUE)

在代码的开头,然后您可以根据需要轻松打开和关闭它。