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

Can create 1d array variables #84

Closed
hadley opened this Issue May 26, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@hadley
Member

hadley commented May 26, 2016

data_frame(x1 = array(1), x2 = rnorm(1))
#> Source: local data frame [1 x 2]
#> 
#>      x1        x2
#>   <dbl>     <dbl>
#> 1     1 0.8534246

I think this should be an error to be consistent with

data_frame(x1 = matrix(1, 1, 1), x2 = rnorm(1))

@hadley hadley changed the title from Can create 1d arrays to Can create 1d array variables May 26, 2016

@krlmlr

This comment has been minimized.

Member

krlmlr commented May 26, 2016

How about silently stripping the .Dim attribute in this case? The outputs of 1:3 and array(1:3) are indistinguishable, but:

> dput(array(1:3))
structure(1:3, .Dim = 3L)
@hadley

This comment has been minimized.

Member

hadley commented May 26, 2016

I think that's reasonable - generally we prefer to complain about bad column types, but this is such a simple transformation it seems ok to be helpful.

@jennybc

This comment has been minimized.

Member

jennybc commented May 28, 2016

I think I just stumbled into this test driving the new mutate_*() functions? I forgot scale() returns a matrix. Here's a really easy way to create a problematic tibble:

iris %>% select(-Species) %>% mutate_each(funs(scale))

Everything seems OK, you can print, str(), View(). But if you use group_by() the wheels start to come off the wagon. You cannot View() this.

iris %>% group_by(Species) %>% mutate_each(funs(scale))

It's even easier to create strange tibbles with mutate_all(), mutate_if(), mutate_at(). I made something I can't str().

@krlmlr krlmlr closed this in 3bb537f Jun 13, 2016

krlmlr pushed a commit that referenced this issue Jun 13, 2016

Kirill Müller
Merge tag 'v1.0-7'
- Tibbles with `POSIXlt` columns can be printed now, the text `<POSIXlt>` is shown as placeholder to encourage usage of `POSIXct` (#86).
- New `is.data_frame()` and `is_data_frame()` (#79).
- Strict checking of integer and logical column indexes. For integers, passing a non-integer index or an out-of-bounds index raises an error. For logicals, only vectors of length 1 or `ncol` are supported. Passing a matrix or an array now raises an error in any case (#83).
- The `.Dim` attribute is silently stripped off columns that are 1d matrices (#84).

krlmlr pushed a commit that referenced this issue Jul 4, 2016

Kirill Müller
Merge tag 'v1.1'
Follow-up release.

- `tibble()` is no longer an alias for `frame_data()` (#82).
- Remove `tbl_df()` (#57).
- `$` returns `NULL` if column not found, without partial matching. A warning is given (#109).
- `[[` returns `NULL` if column not found (#109).

- Reworked output: More concise summary (begins with hash `#` and contains more text (#95)), removed empty line, showing number of hidden rows and columns (#51). The trailing metadata also begins with hash `#` (#101). Presence of row names is indicated by a star in printed output (#72).
- Format `NA` values in character columns as `<NA>`, like `print.data.frame()` does (#69).
- The number of printed extra cols is now an option (#68, @lionel-).
- Computation of column width properly handles wide (e.g., Chinese) characters, tests still fail on Windows (#100).
- `glimpse()` shows nesting structure for lists and uses angle brackets for type (#98).
- Tibbles with `POSIXlt` columns can be printed now, the text `<POSIXlt>` is shown as placeholder to encourage usage of `POSIXct` (#86).
- `type_sum()` shows only topmost class for S3 objects.

- Strict checking of integer and logical column indexes. For integers, passing a non-integer index or an out-of-bounds index raises an error. For logicals, only vectors of length 1 or `ncol` are supported. Passing a matrix or an array now raises an error in any case (#83).
- Warn if setting non-`NULL` row names (#75).
- Consistently surround variable names with single quotes in error messages.
- Use "Unknown column 'x'" as error message if column not found, like base R (#94).
- `stop()` and `warning()` are now always called with `call. = FALSE`.

- The `.Dim` attribute is silently stripped from columns that are 1d matrices (#84).
- Converting a tibble without row names to a regular data frame does not add explicit row names.
- `as_tibble.data.frame()` preserves attributes, and uses `as_tibble.list()` to calling overriden methods which may lead to endless recursion.

- New `has_name() (#102).
- Prefer `tibble()` and `as_tibble()` over `data_frame()` and `as_data_frame()` in code and documentation (#82).
- New `is.tibble()` and `is_tibble()` (#79).
- New `enframe()` that converts vectors to two-column tibbles (#31, #74).
- `obj_sum()` and `type_sum()` show `"tibble"` instead of `"tbl_df"` for tibbles (#82).
- `as_tibble.data.frame()` gains `validate` argument (as in `as_tibble.list()`), if `TRUE` the input is validated.
- Implement `as_tibble.default()` (#71, tidyverse/dplyr#1752).
- `has_rownames()` supports arguments that are not data frames.

- Two-dimensional indexing with `[[` works (#58, #63).
- Subsetting with empty index (e.g., `x[]`) also removes row names.

- Document behavior of `as_tibble.tbl_df()` for subclasses (#60).
- Document and test that subsetting removes row names.

- Don't rely on `knitr` internals for testing (#78).
- Fix compatibility with `knitr` 1.13 (#76).
- Enhance `knit_print()` tests.
- Provide default implementation for `tbl_sum.tbl_sql()` and `tbl_sum.tbl_grouped_df()` to allow `dplyr` release before a `tibble` release.
- Explicit tests for `format_v()` (#98).
- Test output for `NULL` value of `tbl_sum()`.
- Test subsetting in all variants (#62).
- Add missing test from dplyr.
- Use new `expect_output_file()` from `testthat`.
@krlmlr

This comment has been minimized.

Member

krlmlr commented Sep 24, 2016

Should be fixed with devtools::install_github("krlmlr/dplyr@b-1918-grouped-dims") .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment