You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ro...@apache.org on 2019/06/12 11:39:12 UTC
[arrow] branch master updated: ARROW-5190 [R]: Discussion: tibble
dependency in R package
This is an automated email from the ASF dual-hosted git repository.
romainfrancois pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 5750f5a ARROW-5190 [R]: Discussion: tibble dependency in R package
5750f5a is described below
commit 5750f5aff5cf7ea34ba2263f6969919895eae033
Author: Romain Francois <ro...@rstudio.com>
AuthorDate: Wed Jun 12 13:38:59 2019 +0200
ARROW-5190 [R]: Discussion: tibble dependency in R package
`tibble` is now on Suggests. The code still makes tibbles, so that if `tibble` is otherwise loaded, data frames are nicely print, etc... but does not need to specifically `Imports` it.
Author: Romain Francois <ro...@rstudio.com>
Closes #4454 from romainfrancois/ARROW-5190/tibble and squashes the following commits:
18b1e05e <Romain Francois> s/as_tibble/as.data.frame/ in tests
66e63038 <Romain Francois> as.data.frame() needs arguments row.names = NULL, optional = FALSE
240ef90d <Romain Francois> move tibble dependency to Suggests
---
r/DESCRIPTION | 7 +++----
r/NAMESPACE | 6 ++----
r/R/RecordBatch.R | 2 +-
r/R/Table.R | 2 +-
r/R/feather.R | 2 +-
r/R/parquet.R | 2 +-
r/R/read_table.R | 2 +-
r/R/reexports-tibble.R | 20 --------------------
r/man/reexports.Rd | 5 +----
r/tests/testthat/test-RecordBatch.R | 6 +++---
r/tests/testthat/test-Table.R | 10 +++++-----
r/tests/testthat/test-feather.R | 8 +++++---
r/tests/testthat/test-parquet.R | 2 +-
13 files changed, 25 insertions(+), 49 deletions(-)
diff --git a/r/DESCRIPTION b/r/DESCRIPTION
index 58a208c..c38e5a1 100644
--- a/r/DESCRIPTION
+++ b/r/DESCRIPTION
@@ -21,9 +21,9 @@ Encoding: UTF-8
LazyData: true
SystemRequirements: C++11
LinkingTo:
- Rcpp (>= 1.0.0)
+ Rcpp (>= 1.0.1)
Imports:
- Rcpp (>= 1.0.0),
+ Rcpp (>= 1.0.1),
rlang,
purrr,
assertthat,
@@ -31,12 +31,12 @@ Imports:
R6,
vctrs (>= 0.1.0),
fs,
- tibble,
crayon,
bit64
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
Suggests:
+ tibble,
covr,
pkgdown,
rmarkdown,
@@ -74,6 +74,5 @@ Collate:
'read_record_batch.R'
'read_table.R'
'reexports-bit64.R'
- 'reexports-tibble.R'
'write_arrow.R'
'zzz.R'
diff --git a/r/NAMESPACE b/r/NAMESPACE
index 13071b9..d535ea9 100644
--- a/r/NAMESPACE
+++ b/r/NAMESPACE
@@ -38,8 +38,8 @@ S3method(RecordBatchStreamReader,raw)
S3method(RecordBatchStreamWriter,"arrow::io::OutputStream")
S3method(RecordBatchStreamWriter,character)
S3method(RecordBatchStreamWriter,fs_path)
-S3method(as_tibble,"arrow::RecordBatch")
-S3method(as_tibble,"arrow::Table")
+S3method(as.data.frame,"arrow::RecordBatch")
+S3method(as.data.frame,"arrow::Table")
S3method(buffer,"arrow::Buffer")
S3method(buffer,complex)
S3method(buffer,default)
@@ -114,7 +114,6 @@ export(TimeUnit)
export(Type)
export(array)
export(arrow_available)
-export(as_tibble)
export(boolean)
export(buffer)
export(cast_options)
@@ -183,5 +182,4 @@ importFrom(rlang,abort)
importFrom(rlang,dots_n)
importFrom(rlang,list2)
importFrom(rlang,warn)
-importFrom(tibble,as_tibble)
useDynLib(arrow, .registration = TRUE)
diff --git a/r/R/RecordBatch.R b/r/R/RecordBatch.R
index 2b9148a..3ebd81b 100644
--- a/r/R/RecordBatch.R
+++ b/r/R/RecordBatch.R
@@ -85,7 +85,7 @@
}
#' @export
-`as_tibble.arrow::RecordBatch` <- function(x, use_threads = TRUE, ...){
+`as.data.frame.arrow::RecordBatch` <- function(x, row.names = NULL, optional = FALSE, use_threads = TRUE, ...){
RecordBatch__to_dataframe(x, use_threads = use_threads)
}
diff --git a/r/R/Table.R b/r/R/Table.R
index 87e87ac..4c434b0 100644
--- a/r/R/Table.R
+++ b/r/R/Table.R
@@ -66,7 +66,7 @@ table <- function(..., schema = NULL){
}
#' @export
-`as_tibble.arrow::Table` <- function(x, use_threads = TRUE, ...){
+`as.data.frame.arrow::Table` <- function(x, row.names = NULL, optional = FALSE, use_threads = TRUE, ...){
Table__to_dataframe(x, use_threads = use_threads)
}
diff --git a/r/R/feather.R b/r/R/feather.R
index 4a1d9de..c65ea9e 100644
--- a/r/R/feather.R
+++ b/r/R/feather.R
@@ -169,7 +169,7 @@ FeatherTableReader.fs_path <- function(file, mmap = TRUE, ...) {
read_feather <- function(file, columns = NULL, as_tibble = TRUE, use_threads = TRUE, ...){
out <- FeatherTableReader(file, ...)$Read(columns)
if (isTRUE(as_tibble)) {
- out <- as_tibble(out, use_threads = use_threads)
+ out <- as.data.frame(out, use_threads = use_threads)
}
out
}
diff --git a/r/R/parquet.R b/r/R/parquet.R
index d7f389f..8caf356 100644
--- a/r/R/parquet.R
+++ b/r/R/parquet.R
@@ -39,7 +39,7 @@
read_parquet <- function(file, as_tibble = TRUE, use_threads = TRUE, ...) {
tab <- shared_ptr(`arrow::Table`, read_parquet_file(file))
if (isTRUE(as_tibble)) {
- tab <- as_tibble(tab, use_threads = use_threads)
+ tab <- as.data.frame(tab, use_threads = use_threads)
}
tab
}
diff --git a/r/R/read_table.R b/r/R/read_table.R
index b471296..f7a7987 100644
--- a/r/R/read_table.R
+++ b/r/R/read_table.R
@@ -86,5 +86,5 @@ read_table.fs_path <- function(stream) {
#' @rdname read_table
#' @export
read_arrow <- function(stream, use_threads = TRUE){
- as_tibble(read_table(stream))
+ as.data.frame(read_table(stream))
}
diff --git a/r/R/reexports-tibble.R b/r/R/reexports-tibble.R
deleted file mode 100644
index de445c2..0000000
--- a/r/R/reexports-tibble.R
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-#' @importFrom tibble as_tibble
-#' @export
-tibble::as_tibble
diff --git a/r/man/reexports.Rd b/r/man/reexports.Rd
index 66194fe..6951fcf 100644
--- a/r/man/reexports.Rd
+++ b/r/man/reexports.Rd
@@ -1,11 +1,10 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/reexports-bit64.R, R/reexports-tibble.R
+% Please edit documentation in R/reexports-bit64.R
\docType{import}
\name{reexports}
\alias{reexports}
\alias{print.integer64}
\alias{str.integer64}
-\alias{as_tibble}
\title{Objects exported from other packages}
\keyword{internal}
\description{
@@ -14,7 +13,5 @@ below to see their documentation.
\describe{
\item{bit64}{\code{\link[bit64]{print.integer64}}, \code{\link[bit64]{str.integer64}}}
-
- \item{tibble}{\code{\link[tibble]{as_tibble}}}
}}
diff --git a/r/tests/testthat/test-RecordBatch.R b/r/tests/testthat/test-RecordBatch.R
index a492f0f..7d4b27b 100644
--- a/r/tests/testthat/test-RecordBatch.R
+++ b/r/tests/testthat/test-RecordBatch.R
@@ -75,13 +75,13 @@ test_that("RecordBatch", {
schema(dbl = float64(), lgl = boolean(), chr = utf8(), fct = dictionary(int32(), array(letters[1:10])))
)
expect_equal(batch2$column(0), batch$column(1))
- expect_identical(as_tibble(batch2), tbl[,-1])
+ expect_identical(as.data.frame(batch2), tbl[,-1])
batch3 <- batch$Slice(5)
- expect_identical(as_tibble(batch3), tbl[6:10,])
+ expect_identical(as.data.frame(batch3), tbl[6:10,])
batch4 <- batch$Slice(5, 2)
- expect_identical(as_tibble(batch4), tbl[6:7,])
+ expect_identical(as.data.frame(batch4), tbl[6:7,])
})
test_that("RecordBatch with 0 rows are supported", {
diff --git a/r/tests/testthat/test-Table.R b/r/tests/testthat/test-Table.R
index 59234fa..56b0969 100644
--- a/r/tests/testthat/test-Table.R
+++ b/r/tests/testthat/test-Table.R
@@ -88,8 +88,8 @@ test_that("table() handles record batches with splicing", {
expect_equal(tab$schema, batch$schema)
expect_equal(tab$num_rows, 6L)
expect_equal(
- as_tibble(tab),
- vctrs::vec_rbind(as_tibble(batch), as_tibble(batch), as_tibble(batch))
+ as.data.frame(tab),
+ vctrs::vec_rbind(as.data.frame(batch), as.data.frame(batch), as.data.frame(batch))
)
batches <- list(batch, batch, batch)
@@ -97,8 +97,8 @@ test_that("table() handles record batches with splicing", {
expect_equal(tab$schema, batch$schema)
expect_equal(tab$num_rows, 6L)
expect_equal(
- as_tibble(tab),
- vctrs::vec_rbind(!!!purrr::map(batches, as_tibble))
+ as.data.frame(tab),
+ vctrs::vec_rbind(!!!purrr::map(batches, as.data.frame))
)
})
@@ -113,7 +113,7 @@ test_that("table() handles ... of arrays, chunked arrays, vectors", {
tab$schema,
schema(a = int32(), b = int32(), c = float64(), x = int32(), y = utf8())
)
- res <- as_tibble(tab)
+ res <- as.data.frame(tab)
expect_equal(names(res), c("a", "b", "c", "x", "y"))
expect_equal(res,
tibble::tibble(a = 1:10, b = 1:10, c = v, x = 1:10, y = letters[1:10])
diff --git a/r/tests/testthat/test-feather.R b/r/tests/testthat/test-feather.R
index f97348c..6d874b3 100644
--- a/r/tests/testthat/test-feather.R
+++ b/r/tests/testthat/test-feather.R
@@ -72,7 +72,8 @@ test_that("feather handles columns = <names>", {
tab1 <- read_feather(tf1, columns = c("x", "y"))
expect_is(tab1, "data.frame")
- expect_equal(tib[, c("x", "y")], as_tibble(tab1))
+ expect_equal(tib$x, tab1$x)
+ expect_equal(tib$y, tab1$y)
unlink(tf1)
})
@@ -87,7 +88,8 @@ test_that("feather handles columns = <integer>", {
tab1 <- read_feather(tf1, columns = 1:2)
expect_is(tab1, "data.frame")
- expect_equal(tib[, c("x", "y")], as_tibble(tab1))
+ expect_equal(tib$x, tab1$x)
+ expect_equal(tib$y, tab1$y)
unlink(tf1)
})
@@ -101,7 +103,7 @@ test_that("feather read/write round trip", {
tab1 <- read_feather(tf1, as_tibble = FALSE)
expect_is(tab1, "arrow::Table")
- expect_equal(tib, as_tibble(tab1))
+ expect_equal(tib, as.data.frame(tab1))
unlink(tf1)
})
diff --git a/r/tests/testthat/test-parquet.R b/r/tests/testthat/test-parquet.R
index 81637f3..f0a742d 100644
--- a/r/tests/testthat/test-parquet.R
+++ b/r/tests/testthat/test-parquet.R
@@ -26,7 +26,7 @@ test_that("reading a known Parquet file to tibble", {
# TODO: assert more about the contents
})
-test_that("as_tibble with and without threads", {
+test_that("as.data.frame with and without threads", {
expect_identical(
read_parquet(pq_file),
read_parquet(pq_file, use_threads = FALSE)