Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.

Possible error in BulkCreateFromHITLayout #114

Closed
tylerandrewscott opened this issue Jul 1, 2016 · 4 comments
Closed

Possible error in BulkCreateFromHITLayout #114

tylerandrewscott opened this issue Jul 1, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@tylerandrewscott
Copy link

Hello,
I am having trouble getting the function BulkCreateFromHITLayout to work, as it gives me the following error:

Error in GenerateHITLayoutParameter(names = NULL, values = unlist(input[i, :
length(names) must equal length(values)

In looking at the code for BulkCreateFromHITLayout() (pasted below), I believe that the issue relates to the fact that in the call to GenerateHITLayoutParameter(), names=NULL, but running unlist(input[i, , drop = TRUE])) results in an unnamed value. I apologize if I am missing something obvious here.

 if (!"hit.type" %in% names(a)) {
        HITs[[i]] <- CreateHIT(hitlayoutid = hitlayoutid, 
            hitlayoutparameters = GenerateHITLayoutParameter(names = NULL, 
              values = unlist(input[i, , drop = TRUE])), 
            annotation = annotation[i], hit.type = register$HITTypeId, 
            verbose = verbose, ...)
    }
@leeper leeper added the bug label Jul 4, 2016
@leeper leeper self-assigned this Jul 4, 2016
@leeper leeper added this to the v0.8 milestone Jul 4, 2016
@leeper
Copy link
Member

leeper commented Jul 4, 2016

Thanks. I think you're right. I'm on the road at the moment, but will try to fix this as soon as I can.

@leeper
Copy link
Member

leeper commented Jul 23, 2016

Hey, @tylerascott, I believe I've fixed this. Will you give it a try and make sure it works for you as expect? (And sorry for the delay in getting it fixed.)

@tylerandrewscott
Copy link
Author

Hello,
Thanks for your help on this. I just downloaded the updated version and
tried BulkCreateFromHITLayout function, and works as expected. By-the-by,
one other minor issue I encountered was with the "annotation" option --
when annotation is given as just one character string, this "if" statement:

if (length(annotation) != 1) {
annotation <- rep(annotation[1], nrow(input))
}

is not activated. Then, if this later if statement is TRUE:

for (i in 1:nrow(input)) {
if (!"hit.type" %in% names(a)) {
HITs[[i]] <- CreateHIT(hitlayoutid = hitlayoutid,
hitlayoutparameters = GenerateHITLayoutParameter(names =
names(input),
values = unlist(input[i, , drop = TRUE])),
annotation = annotation[i], hit.type = register$HITTypeId,
verbose = verbose, ...)
}

the function doesn't find an annotation for anything but i = 1, so only
some of the created HITs are annotated. I think that the simplest fix for
this might be to simply to switch the if statement to:

if (length(annotation) == 1) {
annotation <- rep(annotation[1], nrow(input))
}

This worked for me, but I'm unsure if this has any unforeseen consequences.

Anyways, the important parts of the function seem to be working great.
Thanks so much for your work on the MTurkR package, I really appreciate it,
and hope to be able to cite the package in published work soon!

-tyler

On Sat, Jul 23, 2016 at 7:31 AM, Thomas J. Leeper notifications@github.com
wrote:

Hey, @tylerascott https://github.com/tylerascott, I believe I've fixed
this. Will you give it a try and make sure it works for you as expect? (And
sorry for the delay in getting it fixed.)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#114 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADhv3-FtI6dKP88uvAQRmexIZqoER-WWks5qYiWugaJpZM4JC0Rh
.

Tyler Scott
Assistant Professor of Public Policy
Department of Public Administration and Policy
School of Public and International Affairs, University of Georgia
tyler.scott@uga.edu | 263.632.3362 |
http://spia.uga.edu/faculty_pages/tyler.scott/
http://tyler.andrew.scott.com

leeper added a commit that referenced this issue Jul 26, 2016
@leeper
Copy link
Member

leeper commented Jul 26, 2016

Yes, that's definitely a mistake. Just sent a patch for it. Thanks for your bug reports! Very much appreciated.

@leeper leeper closed this as completed Jul 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants