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

Add multiple rows #142

Merged
merged 1 commit into from Aug 15, 2016
Merged

Add multiple rows #142

merged 1 commit into from Aug 15, 2016

Conversation

@jennybc
Copy link
Member

@jennybc jennybc commented Aug 5, 2016

add_row() wasn't actually adding multiple rows. It was just adding one.

It will still add a row of NAs when no input is given, which I gather is intentional, from existing tests. My actual interest was in recycling with vector input, hence the test for that.

Demo with one of the examples:

df <- tibble(x = 1:3, y = 3:1)

## BEFORE
## multiple rows weren't, in fact, being added; also warnings
add_row(df, x = 4:5, y = 0:-1)
#> # A tibble: 4 × 2
#>       x     y
#> * <int> <int>
#> 1     1     3
#> 2     2     2
#> 3     3     1
#> 4     4     0
#> Warning messages:
#> 1: In rbind(deparse.level, ...) :
#>   number of items to replace is not a multiple of replacement length
#> 2: In rbind(deparse.level, ...) :
#>   number of items to replace is not a multiple of replacement length

## AFTER
## vector inputs do add multiple rows, w/ no warnings
add_row(df, x = 4:5, y = 0:-1)
#> # A tibble: 5 × 2
#>       x     y
#> * <int> <int>
#> 1     1     3
#> 2     2     2
#> 3     3     1
#> 4     4     0
#> 5     5    -1
@codecov-io
Copy link

@codecov-io codecov-io commented Aug 5, 2016

Current coverage is 99.38% (diff: 100%)

Merging #142 into master will not change coverage

@@             master       #142   diff @@
==========================================
  Files            15         15          
  Lines           650        650          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits            646        646          
  Misses            4          4          
  Partials          0          0          

Powered by Codecov. Last update dbe66cf...21541de

@krlmlr krlmlr merged commit 21541de into tidyverse:master Aug 15, 2016
3 checks passed
krlmlr added a commit that referenced this issue Aug 15, 2016
- `add_row()` now can add multiple rows, with recycling (#142, @jennybc).
@krlmlr
Copy link
Member

@krlmlr krlmlr commented Aug 15, 2016

Thanks! I tweaked it a bit, and will add before-after logic on top.

krlmlr added a commit that referenced this issue Aug 16, 2016
- Internal: Cleanup of formatting code.
- `add_row()` now correctly handles existing columns of type `list` that are not updated (#148).
- `nibble()` has been renamed to `tribble()`, stands for "transposed tibble" (#143).
- `add_row()` and `add_column()` gain `.before` and `.after` arguments which indicate the row (by number) or column (by number or name) before or after which the new data are inserted. Updated or added columns cannot be named `.before` or `.after` (#99).
- New `add_column()`, analogously to `add_row()` (#99).
- `add_row()` now can add multiple rows, with recycling (#142, @jennybc).
krlmlr added a commit that referenced this issue Aug 26, 2016
- The `tibble.width` option is used for `glimpse()` only if it is finite (#153, @kwstat).
- New `as_tibble.poly()` to support conversion of a `poly` object to a tibble (#110).
- `add_row()` now correctly handles existing columns of type `list` that are not updated (#148).
- `all.equal()` doesn't throw an error anymore if one of the columns is named `na.last`, `decreasing` or `method` (#107, @BillDunlap).

- New `add_column()`, analogously to `add_row()` (#99).
- `print.tbl_df()` gains `n_extra` method and will have the same interface as `trunc_mat()` from now on.
- `add_row()` and `add_column()` gain `.before` and `.after` arguments which indicate the row (by number) or column (by number or name) before or after which the new data are inserted. Updated or added columns cannot be named `.before` or `.after` (#99).
- Rename `frame_data()` to `tribble()`, stands for "transposed tibble". The former is still available as alias (#132, #143).

- `add_row()` now can add multiple rows, with recycling (#142, @jennybc).
- Use multiply character `×` instead of `x` when printing dimensions (#126). Output tests had to be disabled for this on Windows.
- Back-tick non-semantic column names on output (#131).
- Use `dttm` instead of `time` for `POSIXt` values (#133), which is now used for columns of the `difftime` class.
- Better output for 0-row results when total number of rows is unknown (e.g., for SQL data sources).

- New object summary vignette that shows which methods to define for custom vector classes to be used as tibble columns (#151).
- Added more examples for `print.tbl_df()`, now using data from `nycflights13` instead of `Lahman` (#121), with guidance to install `nycflights13` package if necessary (#152).
- Minor changes in vignette (#115, @helix123).
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants