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

Tests for empty data frames. #413

Closed
liori opened this issue May 1, 2014 · 3 comments
Closed

Tests for empty data frames. #413

liori opened this issue May 1, 2014 · 3 comments
Assignees
Labels
bug an unexpected problem or unintended behavior
Milestone

Comments

@liori
Copy link

liori commented May 1, 2014

> inner_join(data.frame(x=c()), data.frame(x=c(1)), by="x")
Error: index out of bounds

I would expect the result to be equivalent to data.frame(x=c()).

@liori liori changed the title union raises an error on an empty data frame inner_join raises an error on an empty data frame May 1, 2014
@hs3180
Copy link
Contributor

hs3180 commented May 12, 2014

and summarise doesn't works too
summarise(data.frame(a = numeric(0)), sum(a))

@hadley hadley changed the title inner_join raises an error on an empty data frame Tests for empty data frames. Aug 1, 2014
@hadley hadley added the bug label Aug 1, 2014
@hadley hadley added this to the 0.3.1 milestone Aug 1, 2014
@hadley hadley self-assigned this Aug 1, 2014
@romainfrancois
Copy link
Member

The problem for the original issue is that c() gives NULL and not a vector, e.g this works:

inner_join(data.frame(x=numeric(0)), data.frame(x=c(1)), by="x")

The original data not only has no rows but also no columns:

> data <- data.frame(x = c())
> data
tableau de données (data frame) avec 0 colonnes et 0 lignes

@romainfrancois
Copy link
Member

And I just fixed the second problem, i.e. the one reported by @hs3180 which was hidden deep inside.

> summarise(data.frame(a = numeric(0)), sum(a) )
  sum(a)
1      0

@hadley hadley closed this as completed Nov 18, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants