You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/17 12:16:31 UTC

[GitHub] [arrow] thisisnic opened a new pull request #10343: ARROW-12758: [R] Add examples to more function documentation

thisisnic opened a new pull request #10343:
URL: https://github.com/apache/arrow/pull/10343


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-842277252


   https://issues.apache.org/jira/browse/ARROW-12758


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] jonkeane closed pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
jonkeane closed pull request #10343:
URL: https://github.com/apache/arrow/pull/10343


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] jonkeane commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
jonkeane commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-850409747


   Ah, yes both of those jobs would be good — it didn't occur to me that r-without-arrow should be added too, but in retrospect it's obvious!
   
   We/you could also include those fixes in https://issues.apache.org/jira/browse/ARROW-12901 which is a follow on to the other examples PR I (accidentally) merged prematurely 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] jonkeane commented on a change in pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
jonkeane commented on a change in pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#discussion_r636097187



##########
File path: r/R/compute.R
##########
@@ -264,6 +287,9 @@ is_in.ArrowDatum <- function(x, table, ...) {
 #' @param x `Array` or `ChunkedArray`
 #' @return A `StructArray` containing "values" (same type as `x`) and "counts"
 #' `Int64`.
+#' @examples
+#' cyl_vals <- Array$create(mtcars$cyl)
+#' value_counts(cyl_vals)

Review comment:
       Yeah, absolutely. It's possible there's some good reason it's not possible, but we could figure that out on the ticket or when we do that ticket




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] thisisnic commented on a change in pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
thisisnic commented on a change in pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#discussion_r636074076



##########
File path: r/R/compute.R
##########
@@ -264,6 +287,9 @@ is_in.ArrowDatum <- function(x, table, ...) {
 #' @param x `Array` or `ChunkedArray`
 #' @return A `StructArray` containing "values" (same type as `x`) and "counts"
 #' `Int64`.
+#' @examples
+#' cyl_vals <- Array$create(mtcars$cyl)
+#' value_counts(cyl_vals)

Review comment:
       Reckon it's worth me opening a ticket for this?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] thisisnic commented on a change in pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
thisisnic commented on a change in pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#discussion_r634763838



##########
File path: r/R/array.R
##########
@@ -84,6 +84,28 @@
 #'
 #' @rdname array
 #' @name array
+#' @examples
+#' vals <- 1:10
+#' my_array <- Array$create(vals)
+#' my_array$type
+#' my_array$cast(int8())
+#' 
+#' # Check if value is null; zero-indexed
+#' na_array <- Array$create(c(1:5, NA))
+#' na_array$IsNull(0)
+#' na_array$IsNull(5)
+#' na_array$IsValid(5)
+#' na_array$null_count
+#' 
+#' # zero-copy slicing; the offset of the new Array will be the same as the index passed to $Slice

Review comment:
       Ooh, reckon that would fit nicely in one of the vignettes?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] thisisnic commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
thisisnic commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-843050674


   @github-actions crossbow submit test-r-minimal-build


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] thisisnic commented on a change in pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
thisisnic commented on a change in pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#discussion_r636794167



##########
File path: r/R/compute.R
##########
@@ -264,6 +287,9 @@ is_in.ArrowDatum <- function(x, table, ...) {
 #' @param x `Array` or `ChunkedArray`
 #' @return A `StructArray` containing "values" (same type as `x`) and "counts"
 #' `Int64`.
+#' @examples
+#' cyl_vals <- Array$create(mtcars$cyl)
+#' value_counts(cyl_vals)

Review comment:
       https://issues.apache.org/jira/browse/ARROW-12847




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-842465697


   Revision: 03ff83c77b8d2d4451212e2ec26d425e1a4464c1
   
   Submitted crossbow builds: [ursacomputing/crossbow @ actions-418](https://github.com/ursacomputing/crossbow/branches/all?query=actions-418)
   
   |Task|Status|
   |----|------|
   |test-r-minimal-build|[![Azure](https://dev.azure.com/ursacomputing/crossbow/_apis/build/status/ursacomputing.crossbow?branchName=actions-418-azure-test-r-minimal-build)](https://dev.azure.com/ursacomputing/crossbow/_build/latest?definitionId=1&branchName=actions-418-azure-test-r-minimal-build)|


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] jonkeane commented on a change in pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
jonkeane commented on a change in pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#discussion_r640923818



##########
File path: r/R/chunked-array.R
##########
@@ -57,6 +57,25 @@
 #' @rdname ChunkedArray
 #' @name ChunkedArray
 #' @seealso [Array]
+#' @examples
+#' # Pass items into chunked_array as separate objects to create chunks
+#' class_scores <- chunked_array(c(87, 88, 89), c(94, 93, 92), c(71, 72, 73))
+#' class_scores$num_chunks
+#' 
+#' # When taking a Slice from a chunked_array, chunks are preserved
+#' class_scores$Slice(2,length = 5)

Review comment:
       ```suggestion
   #' class_scores$Slice(2, length = 5)
   ```

##########
File path: r/R/type.R
##########
@@ -57,6 +57,13 @@ FLOAT_TYPES <- c("float16", "float32", "float64", "halffloat", "float", "double"
 #' @param x an R vector
 #'
 #' @return an arrow logical type
+#' @examples
+#' type(1:10)
+#' type(1L:10L)
+#' type(c(1,1.5,2))

Review comment:
       ```suggestion
   #' type(c(1, 1.5, 2))
   ```

##########
File path: r/R/chunked-array.R
##########
@@ -57,6 +57,25 @@
 #' @rdname ChunkedArray
 #' @name ChunkedArray
 #' @seealso [Array]
+#' @examples
+#' # Pass items into chunked_array as separate objects to create chunks
+#' class_scores <- chunked_array(c(87, 88, 89), c(94, 93, 92), c(71, 72, 73))
+#' class_scores$num_chunks
+#' 
+#' # When taking a Slice from a chunked_array, chunks are preserved
+#' class_scores$Slice(2,length = 5)
+#' 
+#' # You can combine Take and SortIndices to return a ChunkedArray with 1 chunk 
+#' # containing all values, ordered.
+#' class_scores$Take(class_scores$SortIndices(descending = TRUE))
+#' 
+#' # If you pass a list into chunked_array, you get a list of length 1
+#' list_scores <- chunked_array(list(c(9.9, 9.6, 9.5), c(8.2,8.3,8.4), c(10.0, 9.9, 9.8)))

Review comment:
       ```suggestion
   #' list_scores <- chunked_array(list(c(9.9, 9.6, 9.5), c(8.2, 8.3, 8.4), c(10.0, 9.9, 9.8)))
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ianmcook commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
ianmcook commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-850407397


   Some of these examples should be changed to use `@examplesIf arrow_available()`
   
   See the failure in yesterday's `test-r-without-arrow` job:
   https://dev.azure.com/ursacomputing/crossbow/_build/results?buildId=5784&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb&t=d9b15392-e4ce-5e4c-0c8c-b69645229181&l=306
   
   I guess in the future, when adding examples, we should run:
   ```
   @github-actions crossbow submit test-r-minimal-build test-r-without-arrow
   ```
   
   @thisisnic could you open a new PR to fix that when you have a chance? Thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] thisisnic commented on a change in pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
thisisnic commented on a change in pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#discussion_r636072713



##########
File path: r/R/compute.R
##########
@@ -229,6 +233,25 @@ all.ArrowDatum <- function(..., na.rm = FALSE){
 #' as `x` with the (0-based) indexes into `table`. `is_in()` returns a
 #' `boolean`-type `Array` of the same length as `x` with values indicating
 #' per element of `x` it it is present in `table`.
+#' @examples
+#' # note that the returned value is 0-indexed
+#' cars_tbl <- Table$create(name = rownames(mtcars), mtcars)
+#' match_arrow(Array$create("Mazda RX4 Wag"), cars_tbl$name)

Review comment:
       Good catch there - this has been implemented for all ArrowDatum objects.  I also had a read of the docs for the C++ compute function and experimented with different objects, and it appears that the output type == the x input type, so I have documented this as well now.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-843002079


   Revision: 10d93ad9681e03a8967558509a008cdac525ff2f
   
   Submitted crossbow builds: [ursacomputing/crossbow @ actions-420](https://github.com/ursacomputing/crossbow/branches/all?query=actions-420)
   
   |Task|Status|
   |----|------|
   |test-r-minimal-build|[![Azure](https://dev.azure.com/ursacomputing/crossbow/_apis/build/status/ursacomputing.crossbow?branchName=actions-420-azure-test-r-minimal-build)](https://dev.azure.com/ursacomputing/crossbow/_build/latest?definitionId=1&branchName=actions-420-azure-test-r-minimal-build)|


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] thisisnic commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
thisisnic commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-842959089


   @github-actions crossbow submit test-r-minimal-build


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-842277252






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] thisisnic commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
thisisnic commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-842421889


   @github-actions crossbow submit test-r-minimal-build


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] thisisnic commented on pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
thisisnic commented on pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#issuecomment-842421889


   @github-actions crossbow submit test-r-minimal-build


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] jonkeane commented on a change in pull request #10343: ARROW-12758: [R] Add examples to more function documentation

Posted by GitBox <gi...@apache.org>.
jonkeane commented on a change in pull request #10343:
URL: https://github.com/apache/arrow/pull/10343#discussion_r634453920



##########
File path: r/R/buffer.R
##########
@@ -25,13 +25,19 @@
 #' `buffer()` lets you create an `arrow::Buffer` from an R object
 #' @section Methods:
 #'
-#' - `$is_mutable()` :
-#' - `$ZeroPadding()` :
-#' - `$size()` :
-#' - `$capacity()`:
+#' - `$is_mutable` : is this buffer mutable?
+#' - `$ZeroPadding()` : zero bytes in padding, i.e. bytes between size and capacity
+#' - `$size` : size in memory, in bytes
+#' - `$capacity`: possible capacity, in bytes 

Review comment:
       Thank you for catching all of these that had `()` and shouldn't have + adding in the explanations 

##########
File path: r/R/array.R
##########
@@ -84,6 +84,28 @@
 #'
 #' @rdname array
 #' @name array
+#' @examples
+#' vals <- 1:10
+#' my_array <- Array$create(vals)
+#' my_array$type
+#' my_array$cast(int8())
+#' 
+#' # Check if value is null; zero-indexed
+#' na_array <- Array$create(c(1:5, NA))
+#' na_array$IsNull(0)
+#' na_array$IsNull(5)
+#' na_array$IsValid(5)
+#' na_array$null_count
+#' 
+#' # zero-copy slicing; the offset of the new Array will be the same as the index passed to $Slice

Review comment:
       This is probably (definitely) not the right place for it, and feel free to punt on this, but it would be nice to have a description of why one might want zero-copy and what the benefits of it are.

##########
File path: r/R/array.R
##########
@@ -84,6 +84,28 @@
 #'
 #' @rdname array
 #' @name array
+#' @examples
+#' vals <- 1:10

Review comment:
       Is `vals` here reused? I don't see it, but might be missing it in code folding... If not, it might be clearer to use `1:10` in the line below

##########
File path: r/R/compute.R
##########
@@ -229,6 +233,25 @@ all.ArrowDatum <- function(..., na.rm = FALSE){
 #' as `x` with the (0-based) indexes into `table`. `is_in()` returns a
 #' `boolean`-type `Array` of the same length as `x` with values indicating
 #' per element of `x` it it is present in `table`.
+#' @examples
+#' # note that the returned value is 0-indexed
+#' cars_tbl <- Table$create(name = rownames(mtcars), mtcars)
+#' match_arrow(Array$create("Mazda RX4 Wag"), cars_tbl$name)

Review comment:
       Would it be helpful to include something like `match_arrow(Scalar$create("Mazda RX4 Wag"), cars_tbl$name)` as well to show that one can use a scalar or an array? It looks like the docs above don't actually mention this, so maybe it's an off-label use that we should avoid? Or it's been added and we should document it...

##########
File path: r/R/compute.R
##########
@@ -264,6 +287,9 @@ is_in.ArrowDatum <- function(x, table, ...) {
 #' @param x `Array` or `ChunkedArray`
 #' @return A `StructArray` containing "values" (same type as `x`) and "counts"
 #' `Int64`.
+#' @examples
+#' cyl_vals <- Array$create(mtcars$cyl)
+#' value_counts(cyl_vals)

Review comment:
       This is less a concern of the examples, and more the code for the `StructArray` print method (I think): I'm a little surprised that the names `value` and `counts` aren't displayed:
   
   ```
   > value_counts(Array$create(mtcars$cyl))
   StructArray
   <struct<values: double, counts: int64>>
   -- is_valid: all not null
   -- child 0 type: double
     [
       6,
       4,
       8
     ]
   -- child 1 type: int64
     [
       7,
       11,
       14
     ]
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org