2015-03-02 22 views
1

我正在嘗試使用包MTurkR(使用OS MAC 10.9)通過R向亞馬遜的mTurk發佈資格考試。複製資格示例MTurkR

當我試圖複製的資格例如貼here的例子中,我得到了以下錯誤消息:

Error in CreateQualificationType(name = "A new coding test 2", description = "Test of coding ability", : No Namespace specified in 'test' 

從在下例中爲我的代碼和輸出如下:

# load QuestionForm and AnswerKey 
QuestionForm <- paste0(scan(file="/Users/Desktop/QualExam.xml", what="character", sep="\n"), collapse="") 
    >Read 3 items 
AnswerKey <- paste0(scan(file="/Users/Desktop/QualExamAnswers.xml", what="character", sep="\n"), collapse="") 
    >Read 3 items 

# create new QualificationType 
newqual <- CreateQualificationType(name="A new coding test 2", 
    description="Test of coding ability", 
    status="Active", 
    test.duration=seconds(hours=1), 
    test=QuestionForm, 
    answerkey=AnswerKey, 
    validate.test=TRUE, 
    validate.answerkey=TRUE, 
    sandbox=TRUE) 
    >Error in CreateQualificationType(name = "A new coding test 2", description = "Test of coding ability", : No Namespace specified in 'test' 

我粘貼示例中的文本以創建QualExam.xmlQualExamAnswers.xml文件。

當我運行修改後的代碼,我得到以下錯誤:

> QuestionForm <- paste0(readLines("/Users/Desktop/QuestionForm_Example.xml"), collapse = "") 
Warning message: 
In readLines("/Users/Desktop/QuestionForm_Example.xml") : 
    incomplete final line found on '/Users/Desktop/QuestionForm_Example.xml' 

>AnswerKey <- paste0(readLines("/User/Desktop/AnswerKey_Example.xml"), collapse = "") 
Warning message: 
In readLines("/Users/Desktop/AnswerKey_Example.xml") : 
    incomplete final line found on '/Users/Desktop/AnswerKey_Example.xml' 
>newqual <- CreateQualificationType(name="Classifier: Basic", 
    description="This qualification exam tests basic understanding of speech", 
    status="Active", 
    test.duration=seconds(hours=1), 
    test=QuestionForm, 
    answerkey=AnswerKey, 
    validate.test=TRUE, 
    validate.answerkey=TRUE, 
    sandbox=sandbox.v) 
Error in CreateQualificationType(name = "Classifier: Basic", description = "This qualification exam tests basic understanding of speech", : 
    No Namespace specified in 'test' 

我的會話信息如下:

sessionInfo() 
R version 2.15.1 (2012-06-22) 
Platform: i386-apple-darwin9.8.0/i386 (32-bit) 

locale: 
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] MTurkR_0.4 

loaded via a namespace (and not attached): 
[1] digest_0.6.4 RCurl_1.95-4.1 XML_3.98-1.1 

請幫助。

+0

您是否準確複製了示例?我無法準確複製這一點。你也可以更新你的問題,包括'sessionInfo()'的輸出嗎? – Thomas 2015-03-02 18:29:40

+0

感謝您編輯鏈接@Thomas。我修改了這個問題,並更新了有關我在嘗試運行此示例時遇到的錯誤的更新信息。 – User7598 2015-03-02 23:35:59

+0

'QuestionForm_Example.xml' [validates](http://validator.w3.org/check)但缺少DOCTYPE和字符編碼。這是問題嗎? – User7598 2015-03-03 02:31:28

回答

1

這不起作用,因爲R沒有更新(您可以更新R here)。您還需要安裝XQuartz 2.7.7

.xml文件已驗證,示例適合我。我的sessionInfo()信息如下:

> sessionInfo() 
R version 3.1.2 (2014-10-31) 
Platform: x86_64-apple-darwin13.4.0 (64-bit) 

locale: 
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] MTurkR_0.6 

loaded via a namespace (and not attached): 
[1] bitops_1.0-6 digest_0.6.8 RCurl_1.95-4.5 tcltk_3.1.2 tools_3.1.2 XML_3.98-1.1