Not 100% sure about the root cause (could be also some bad logic in my
script), but I managed to track it as far as addOrder - to me the following
code seems very dubious at least:

    for (i in 1:length(price)) {
        if(is.null(prefer[i])) prefer[i] = ''

Notice that the function has a parameter *prefer* with a default value of
NULL. The first time this loop is entered, is.null(prefer[1]) is TRUE,
thus, prefer[i] is set to ''. However, subsequent values will be NA, thus,
the if is not entered and prefer[2] will be left as NA.

Probably better to initialize prefer prior to the loop?

if(is.null(prefer)) prefer = rep(NULL, length(price))

Thanks,
Ivan

	[[alternative HTML version deleted]]

