Skip to content

[R] Convert arrow dictionary to R factor via as.data.frame.nanoarrow_array_stream()? #513

@eitsupi

Description

@eitsupi

Maybe related to #220

I noticed that if we convert nanoarrow_array_stream to data.frame, the dictionary becomes a character.

stream <- data.frame(
  x = as.factor(letters[1:5]),
  y = as.factor(1:5)
) |>
  nanoarrow::as_nanoarrow_array_stream()

stream
#> <nanoarrow_array_stream struct<x: dictionary(int32)<string>, y: dictionary(int32)<string>>>
#>  $ get_schema:function ()
#>  $ get_next  :function (schema = x$get_schema(), validate = TRUE)
#>  $ release   :function ()
stream |>
  tibble::as_tibble()
#> # A tibble: 5 × 2
#>   x     y
#>   <chr> <chr>
#> 1 a     1
#> 2 b     2
#> 3 c     3
#> 4 d     4
#> 5 e     5

Created on 2024-06-09 with reprex v2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions