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

mutating, arranging, summarizing empty data frames fails with "not compatible with STRSXP" #1142

Closed
richierocks opened this issue May 18, 2015 · 8 comments
Assignees
Milestone

Comments

@richierocks
Copy link

@richierocks richierocks commented May 18, 2015

To reproduce:

data.frame() %>% mutate()
## Error: not compatible with STRSXP

data.frame() %>% arrange()
## Error: not compatible with STRSXP

data.frame() %>% summarize()
## Error: not compatible with STRSXP

The _ versions also fail.

select, filter, group_by work OK.

Related: [ fails inside mutate

@hadley hadley added this to the 0.5 milestone May 19, 2015
@romainfrancois romainfrancois self-assigned this Jun 25, 2015
@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Jun 25, 2015

I fixed mutate for the example above. Not sure though how to deal with this:

data.frame() %>% mutate( x = 2L )

@hadley
Copy link
Member

@hadley hadley commented Jun 25, 2015

@romainfrancois shouldn't that be an error because the output is a different length to the input?

@hadley
Copy link
Member

@hadley hadley commented Jun 25, 2015

Another good test case would be data.frame() %>% mutate(x = numeric())

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Jun 25, 2015

Now I get:

> data.frame() %>% mutate(x = 2L)
[1] x
<0 rows> (or 0-length row.names)

Because a length 1 result in mutate is recycled, so here recycled 0 times, but I can make this special case an error if that makes more sense.

romainfrancois added a commit that referenced this issue Jun 25, 2015
@hadley
Copy link
Member

@hadley hadley commented Jun 25, 2015

Ah, I forgot about that principle. I think either way is probably ok, but recycling to length 0 is a little less frustrating for people.

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Jun 25, 2015

In that case I think we can close this.

@abresler
Copy link

@abresler abresler commented Aug 25, 2015

I think this issue has returned with some of the new updates. I have empty data_frames that I am trying to bind and it now returns the dreaded

not compatible with STRSXP 

@hadley
Copy link
Member

@hadley hadley commented Aug 25, 2015

@abresler could you please file a new issue with a minimal reprex

@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants