diff --git a/r/R/feather.R b/r/R/feather.R index e1b74bdda9c32..420307063ba15 100644 --- a/r/R/feather.R +++ b/r/R/feather.R @@ -17,8 +17,8 @@ #' Write data in the Feather format #' -#' @param data `data.frame` or RecordBatch -#' @param stream A file path or an OutputStream +#' @param x `data.frame` or RecordBatch +#' @param sink A file path or an OutputStream #' #' @export #' @examples @@ -30,20 +30,20 @@ #' }) #' } #' @include arrow-package.R -write_feather <- function(data, stream) { - if (is.data.frame(data)) { - data <- record_batch(data) +write_feather <- function(x, sink) { + if (is.data.frame(x)) { + x <- record_batch(x) } - assert_is(data, "RecordBatch") + assert_is(x, "RecordBatch") - if (is.character(stream)) { - stream <- FileOutputStream$create(stream) - on.exit(stream$close()) + if (is.character(sink)) { + sink <- FileOutputStream$create(sink) + on.exit(sink$close()) } - assert_is(stream, "OutputStream") + assert_is(sink, "OutputStream") - writer <- FeatherTableWriter$create(stream) - ipc___TableWriter__RecordBatch__WriteFeather(writer, data) + writer <- FeatherTableWriter$create(sink) + ipc___TableWriter__RecordBatch__WriteFeather(writer, x) } #' @title FeatherTableWriter class diff --git a/r/R/parquet.R b/r/R/parquet.R index 0584e29925758..706494ab37f6c 100644 --- a/r/R/parquet.R +++ b/r/R/parquet.R @@ -51,7 +51,7 @@ read_parquet <- function(file, #' [Parquet](https://parquet.apache.org/) is a columnar storage file format. #' This function enables you to write Parquet files from R. #' -#' @param table An [arrow::Table][Table], or an object convertible to it. +#' @param x An [arrow::Table][Table], or an object convertible to it. #' @param sink an [arrow::io::OutputStream][OutputStream] or a string which is interpreted as a file path #' @param chunk_size chunk size in number of rows. If NULL, the total number of rows is used. #' @@ -97,7 +97,7 @@ read_parquet <- function(file, #' #' } #' @export -write_parquet <- function(table, +write_parquet <- function(x, sink, chunk_size = NULL, @@ -110,7 +110,7 @@ write_parquet <- function(table, data_page_size = NULL, properties = ParquetWriterProperties$create( - table, + x, version = version, compression = compression, compression_level = compression_level, @@ -130,7 +130,7 @@ write_parquet <- function(table, allow_truncated_timestamps = allow_truncated_timestamps ) ) { - table <- to_arrow(table) + x <- to_arrow(x) if (is.character(sink)) { sink <- FileOutputStream$create(sink) @@ -139,9 +139,9 @@ write_parquet <- function(table, abort("sink must be a file path or an OutputStream") } - schema <- table$schema + schema <- x$schema writer <- ParquetFileWriter$create(schema, sink, properties = properties, arrow_properties = arrow_properties) - writer$WriteTable(table, chunk_size = chunk_size %||% table$num_rows) + writer$WriteTable(x, chunk_size = chunk_size %||% x$num_rows) writer$Close() } diff --git a/r/man/write_feather.Rd b/r/man/write_feather.Rd index 24636a09cb0c5..9bc3797528123 100644 --- a/r/man/write_feather.Rd +++ b/r/man/write_feather.Rd @@ -4,12 +4,12 @@ \alias{write_feather} \title{Write data in the Feather format} \usage{ -write_feather(data, stream) +write_feather(x, sink) } \arguments{ -\item{data}{\code{data.frame} or RecordBatch} +\item{x}{\code{data.frame} or RecordBatch} -\item{stream}{A file path or an OutputStream} +\item{sink}{A file path or an OutputStream} } \description{ Write data in the Feather format diff --git a/r/man/write_parquet.Rd b/r/man/write_parquet.Rd index daeb401997b58..b2471d7a5b79e 100644 --- a/r/man/write_parquet.Rd +++ b/r/man/write_parquet.Rd @@ -4,14 +4,13 @@ \alias{write_parquet} \title{Write Parquet file to disk} \usage{ -write_parquet(table, sink, chunk_size = NULL, version = NULL, +write_parquet(x, sink, chunk_size = NULL, version = NULL, compression = NULL, compression_level = NULL, use_dictionary = NULL, write_statistics = NULL, - data_page_size = NULL, - properties = ParquetWriterProperties$create(table, version = version, - compression = compression, compression_level = compression_level, - use_dictionary = use_dictionary, write_statistics = write_statistics, - data_page_size = data_page_size), + data_page_size = NULL, properties = ParquetWriterProperties$create(x, + version = version, compression = compression, compression_level = + compression_level, use_dictionary = use_dictionary, write_statistics = + write_statistics, data_page_size = data_page_size), use_deprecated_int96_timestamps = FALSE, coerce_timestamps = NULL, allow_truncated_timestamps = FALSE, arrow_properties = ParquetArrowWriterProperties$create(use_deprecated_int96_timestamps @@ -19,7 +18,7 @@ write_parquet(table, sink, chunk_size = NULL, version = NULL, allow_truncated_timestamps = allow_truncated_timestamps)) } \arguments{ -\item{table}{An \link[=Table]{arrow::Table}, or an object convertible to it.} +\item{x}{An \link[=Table]{arrow::Table}, or an object convertible to it.} \item{sink}{an \link[=OutputStream]{arrow::io::OutputStream} or a string which is interpreted as a file path}