Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

jankurianski opened this issue Jun 20, 2016 · 0 comments

Comments

@jankurianski
Copy link

@jankurianski jankurianski commented Jun 20, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.