You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by th...@apache.org on 2022/04/13 08:40:41 UTC
[arrow] branch master updated: MINOR: [R][DOCS] Add sections about `Scalar$create()`
This is an automated email from the ASF dual-hosted git repository.
thisisnic 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 58d9487e79 MINOR: [R][DOCS] Add sections about `Scalar$create()`
58d9487e79 is described below
commit 58d9487e7955c0ebe2fca189e760ecfb5e2b23c5
Author: SHIMA Tatsuya <ts...@gmail.com>
AuthorDate: Wed Apr 13 09:40:31 2022 +0100
MINOR: [R][DOCS] Add sections about `Scalar$create()`
Copied almost the same content as `Array$create()`.
However, only the behavior when a data.frame is passed is special, so an example has been added.
Closes #12744 from eitsupi/fix-scalar-doc
Lead-authored-by: SHIMA Tatsuya <ts...@gmail.com>
Co-authored-by: eitsupi <50...@users.noreply.github.com>
Signed-off-by: Nic Crane <th...@gmail.com>
---
r/R/scalar.R | 14 ++++++++++++++
r/man/Scalar.Rd | 18 ++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/r/R/scalar.R b/r/R/scalar.R
index fac51d2e06..5e56b5697a 100644
--- a/r/R/scalar.R
+++ b/r/R/scalar.R
@@ -24,6 +24,20 @@
#'
#' @description A `Scalar` holds a single value of an Arrow type.
#'
+#' @section Factory:
+#' The `Scalar$create()` factory method instantiates a `Scalar` and takes the following arguments:
+#' * `x`: an R vector, list, or `data.frame`
+#' * `type`: an optional [data type][data-type] for `x`. If omitted, the type will be inferred from the data.
+#' @section Usage:
+#'
+#' ```
+#' a <- Scalar$create(x)
+#' length(a)
+#'
+#' print(a)
+#' a == a
+#' ```
+#'
#' @section Methods:
#'
#' - `$ToString()`: convert to a string
diff --git a/r/man/Scalar.Rd b/r/man/Scalar.Rd
index ca0059d470..83d1bd59a0 100644
--- a/r/man/Scalar.Rd
+++ b/r/man/Scalar.Rd
@@ -7,6 +7,24 @@
\description{
A \code{Scalar} holds a single value of an Arrow type.
}
+\section{Factory}{
+
+The \code{Scalar$create()} factory method instantiates a \code{Scalar} and takes the following arguments:
+\itemize{
+\item \code{x}: an R vector, list, or \code{data.frame}
+\item \code{type}: an optional \link[=data-type]{data type} for \code{x}. If omitted, the type will be inferred from the data.
+}
+}
+
+\section{Usage}{
+\preformatted{a <- Scalar$create(x)
+length(a)
+
+print(a)
+a == a
+}
+}
+
\section{Methods}{
\itemize{