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

tibble() and zero-row data frames #20

Closed
krlmlr opened this issue Jan 6, 2016 · 5 comments
Closed

tibble() and zero-row data frames #20

krlmlr opened this issue Jan 6, 2016 · 5 comments

Comments

@krlmlr
Copy link
Member

krlmlr commented Jan 6, 2016

> tibble(~a, ~b)
Error in dots[[i]] : subscript out of bounds

This should probably return an empty data frame.

CC @kevinushey

@krlmlr krlmlr closed this as completed in 292f606 Jan 7, 2016
krlmlr pushed a commit that referenced this issue Jan 7, 2016
- Non-scalar input to `frame_data()` and `tibble()` creates list-valued columns (#7).
- `frame_data()` and `tibble()` create empty `data_frame` if no rows are given (#20).
- `as_data_frame(NULL)` is 0-row 0-column data frame (#17, @jennybc).
- `lst(NULL)` doesn't raise an error anymore (#17, @jennybc), but always uses deparsed expression as name (even for `NULL`).
- `trunc_mat()` and `print()` use `width` argument also for zero-row and zero-column data frames (#18).
krlmlr pushed a commit that referenced this issue Jan 7, 2016
- Non-scalar input to `frame_data()` and `tibble()` creates list-valued columns (#7).
- `frame_data()` and `tibble()` create empty `data_frame` if no rows are given (#20).
- `as_data_frame(NULL)` is 0-row 0-column data frame (#17, @jennybc).
- `lst(NULL)` doesn't raise an error anymore (#17, @jennybc), but always uses deparsed expression as name (even for `NULL`).
- `trunc_mat()` and `print()` use `width` argument also for zero-row and zero-column data frames (#18).
krlmlr pushed a commit that referenced this issue Mar 2, 2016
- Functions related to `tbl` and `src` stay in `dplyr` (#26). Remove unused `make_tbl()`.
- Non-scalar input to `frame_data()` and `tibble()` (including lists) creates list-valued columns (#7).
- Use C++ implementation for `as_data_frame.matrix()` (#14). Also add former `matrixToDataFrame()` tests, and fix unwanted conversion to factor.
- `as_data_frame(NULL)` is 0-row 0-column data frame (#17, @jennybc). `frame_data()` and `tibble()` create empty `data_frame` if no rows are given (#20).
- `data_frame(NULL)` raises error "must be a 1d atomic vector or list".
- `lst(NULL)` doesn't raise an error anymore (#17, @jennybc), but always uses deparsed expression as name (even for `NULL`).
- `trunc_mat()` and `print()` use `width` argument also for zero-row and zero-column data frames (#18).
- `glimpse()` now (invisibly) returns `x`, so it can be used within a chain of `dplyr` verbs (@edwindj).
- `base::getElement()` now works with tibbles (#9).
- Remove spurious usage of "dplyr" in documentation (#3).
- Almost full test coverage.
krlmlr pushed a commit that referenced this issue May 26, 2016
- Link to the package documentation from the `tibble` help page (#20).
@imanuelcostigan
Copy link
Contributor

A regression in v1.1?

> tibble(~a, ~b)
# Error: Each variable must be a 1d atomic vector or list.
# Problem variables: '~a', '~b'

Is this desired behaviour? I am trying to understand the following:

> tibble(a = numeric(), b = character())
# A tibble: 0 x 2
# ... with 2 variables: a <dbl>, b <chr>

But

> tibble(a = NULL, b = NULL)
# Error: Each variable must be a 1d atomic vector or list.
# Problem variables: 'a', 'b'

Related to: imanuelcostigan/RSQLServer#73

@imanuelcostigan
Copy link
Contributor

To be clear, running these two equivalent calls (in SQL space) result in two different outcomes:

DBI: dbGetQuery(ss$con, "SELECT * FROM AIRLINES WHERE carrier = 'ZZ'")

# [1] carrier name   
# <0 rows> (or 0-length row.names)

dplyr: tbl(ss, "airlines") %>% filter(carrier == 'ZZ')

# Error: Each variable must be a 1d atomic vector or list.
# Problem variables: 'carrier', 'name'

I'm trying to work out what I should expect from upstream dependencies.

@imanuelcostigan
Copy link
Contributor

Pinging @krlmlr. Should I open a new ticket?

@krlmlr
Copy link
Member Author

krlmlr commented Aug 2, 2016

I think this is intended, but please open a new ticket. What type should the new NULL columns have? Also, tibble() is the same as data_frame() now, but was an alias for frame_data() in 1.0.

@github-actions
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants