Skip to content

Commit

Permalink
Use tibble::as.tibble to construct tibbles (#591)
Browse files Browse the repository at this point in the history
Fixes #538
  • Loading branch information
jimhester authored Feb 10, 2017
1 parent 8e7febc commit bd308e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Numeric parser now returns the full string if it contains no numbers (#548).
* `read_table()` can now handle `pipe()` connections (#552).
* The `guess_max` argument now throws errors on inappropriate inputs (#588).
* tibble::as.tibble now used to construct tibbles (#538).

* parsing problems in `read_delim()` and `read_fwf()` when columns are skipped using col_types now report the correct column name (#573, @cb4ds)

Expand Down
8 changes: 3 additions & 5 deletions src/Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void Reader::init(CharacterVector colNames) {
}

RObject Reader::readToDataFrame(int lines) {
int rows = read(lines);
read(lines);

// Save individual columns into a data frame
List out(outNames_.size());
Expand All @@ -53,16 +53,14 @@ RObject Reader::readToDataFrame(int lines) {
out[j++] = collectors_[*it]->vector();
}

out.attr("class") = CharacterVector::create("tbl_df", "tbl", "data.frame");
out.attr("row.names") = IntegerVector::create(NA_INTEGER, -(rows + 1));
out.attr("names") = outNames_;

out = warnings_.addAsAttribute(out);

collectorsClear();
warnings_.clear();

return out;
static Function as_tibble("as_tibble", Environment::namespace_env("tibble"));
return as_tibble(out);
}

int Reader::read(int lines) {
Expand Down

0 comments on commit bd308e9

Please sign in to comment.