Skip to content
11 changes: 10 additions & 1 deletion R/pkg/R/DataFrame.R
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,16 @@ setMethod("collect",

# Note that "binary" columns behave like complex types.
if (!is.null(PRIMITIVE_TYPES[[colType]]) && colType != "binary") {
vec <- do.call(c, col)
valueIndex <- which(!is.na(col))
if (length(valueIndex) > 0 && valueIndex[1] > 1) {
colTail <- col[-(1 : (valueIndex[1] - 1))]
vec <- do.call(c, colTail)
classVal <- class(vec)
vec <- c(rep(NA, valueIndex[1] - 1), vec)
class(vec) <- classVal

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what happened here?
if you want to drop the NA and use the rest to infer the class you can do col[!is.na(col)]

} else {
vec <- do.call(c, col)
}
stopifnot(class(vec) != "list")
df[[colIndex]] <- vec
} else {
Expand Down