cloudyr / MTurkR

R Client for the MTurk Requester API
https://cloud.r-project.org/package=MTurkR
91 stars 18 forks source link

Add HIT pay example to website #33

Closed leeper closed 11 years ago

leeper commented 11 years ago

A nice feature of the RUI batch mode is that it automatically calculates some statistics about pay and time on HITs. Something like the following should do it:

hitstats <- function(hit){
    info <- status(hit=hit)
    assign <- assignments(hit,return.all=TRUE)

    return.list <- list(
                    HITId=info$HITId,
                    HITTypeId=info$HITTypeId,
                    CreationDate=info$CreationTime,
                    Title=info$Title,
                    Description=info$Description,
                    RewardAmount=info$Amount,
                    Assignments=info$NumberofAssignmentsCompleted,
                    AverageTimeOnHIT=mean(assign$SecondsOnHIT),
                    MeanTimeOnHIT=mean(assign$SecondsOnHIT),
                    MedianTimeOnHIT=median(assign$SecondsOnHIT),
                    MeanHourlyWage=round(as.numeric(info$Amount)/assign$MeanTimeOnHIT/3600,2),
                    MedianHourlyWage=round(as.numeric(info$Amount)/assign$MedianTimeOnHIT/3600,2)
                    )
    return(return.list)
}