paleolimbot commented on code in PR #14922:
URL: https://github.com/apache/arrow/pull/14922#discussion_r1063570781


##########
r/tests/testthat/test-Array.R:
##########
@@ -543,6 +543,20 @@ test_that("StructArray methods", {
   expect_identical(dim(a), c(10L, 3L))
 })
 
+test_that("StructArray creation", {
+  # from data.frame
+  a <- StructArray$create(example_data)
+  expect_identical(names(a), c("int", "dbl", "dbl2", "lgl", "false", "chr", 
"fct"))
+  expect_identical(dim(a), c(10L, 7L))
+  expect_r6_class(a, "StructArray")
+
+  # from Arrays
+  str_array <- StructArray$create(Array$create(1:2), Array$create(c("a", "b")))
+  expect_equal(str_array[[1]], Array$create(1:2))
+  expect_equal(str_array[[2]], Array$create(c("a", "b")))
+  expect_r6_class(str_array, "StructArray")

Review Comment:
   Maybe one more from named columns like `StructArray$create(a  = 1:2, b = 
c("a", "b")`?



##########
r/tests/testthat/test-Array.R:
##########
@@ -543,6 +543,20 @@ test_that("StructArray methods", {
   expect_identical(dim(a), c(10L, 3L))
 })
 
+test_that("StructArray creation", {
+  # from data.frame
+  a <- StructArray$create(example_data)
+  expect_identical(names(a), c("int", "dbl", "dbl2", "lgl", "false", "chr", 
"fct"))
+  expect_identical(dim(a), c(10L, 7L))
+  expect_r6_class(a, "StructArray")
+
+  # from Arrays
+  str_array <- StructArray$create(Array$create(1:2), Array$create(c("a", "b")))

Review Comment:
   ```suggestion
     str_array <- StructArray$create(a = Array$create(1:2), b = 
Array$create(c("a", "b")))
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to