Skip to content

using data_frame constructor after growing vectors results in incorrect number of rows #91

@jimhester

Description

@jimhester
cpp11::cpp_function('
data_frame foo() {
  writable::integers x, y;
  for (int i = 0; i < 10; ++i) {
    x.push_back(i);
    y.push_back(i);
  }
  return writable::data_frame({
    "x"_nm = x,
    "y"_nm = y
  });
}')
foo()
#>     x  y
#> 1   0  0
#> 2   1  1
#> 3   2  2
#> 4   3  3
#> 5   4  4
#> 6   5  5
#> 7   6  6
#> 8   7  7
#> 9   8  8
#> 10  9  9
#> 11 NA NA
#> 12 NA NA
#> 13 NA NA
#> 14 NA NA
#> 15 NA NA
#> 16 NA NA

Created on 2020-08-13 by the reprex package (v0.3.0)

cc @thomasp85

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions