0-length character vector is restored as 0-length logical vector #13

Closed
jankurianski opened this Issue Jun 20, 2016 · 0 comments

Projects

None yet

1 participant

@jankurianski

Originally I found a problem trying to send a 0-row data.frame with character row.names through RProtobuf:

> x <- data.frame(A=1:3,B=1:3, row.names=c("apples","oranges","bananas"))
> x <- x[x$A > 5, ]
> serialized <- RProtoBuf::serialize_pb(object=x, connection=NULL)
> y <- RProtoBuf::unserialize_pb(serialized)
Error in attributes(xobj) <- attrib : 
  row names must be 'character' or 'integer', not 'logical'

Then I observed that the problem was in the row.names attr of the data.frame, because a 0-length character vector turns into a 0-length logical vector.

> x <- character(0)
> serialized <- RProtoBuf::serialize_pb(object=x, connection=NULL)
> y <- RProtoBuf::unserialize_pb(serialized)
> y
logical(0)

The problem occurs in both the CRAN version (0.4.3) and the Github master code.

@oliverbock oliverbock pushed a commit to Displayr/rprotobuf that referenced this issue Sep 1, 2016
Ubuntu Issue #13: Ensure 0-length character vectors are correctly deserialized d1a8f9f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment