6

I work with multiple dimensional arrays and when I need to plot I usually convert my data to a tibble through tbl_cube to then plot it with ggplot2. Today the new dplyr 1.0.0 was updated to CRAN, and I found that now tbl_cube is no more available. And I could not found a replacement to tbl_cube. I did something like this toy example before today to get a plot:

test_data1 <- array(1:50, c(5,5,2))
test_data2 <- array(51:100, c(5,5,2))

# list of my arrays
test_data <- list(exp1 = test_data1, exp2= test_data2)

# list of the dimentions
dims_list <- list(lat = 1:5, lon = 1:5, var = c('u','v'))

new_data <- as_tibble(tbl_cube(dimensions = dims_list, measures = test_data))

# Make some random plot
ggplot(new_data, aes(x=lon,y=lat)) +
geom_tile(aes(fill=exp2))+
geom_contour(aes(z=exp1),col='black')

This example runs and works with previous dplyr release, but not now since tbl_cube does not exist anymore. I know that in this example the third dimension is not used to do the plot but I wanted to show that I need something to used over at least a 3D array or even a 4D.

Any suggestion of how to solve this in an easy way such as tbl_cube ?

Santiago I. Hurtado
  • 1,113
  • 1
  • 10
  • 23
  • 8
    From the change log, https://dplyr.tidyverse.org/news/index.html. It looks like it is in a new package: "tbl_cube() and nasa have been pulled out into a separate cubelyr package (#4429)." – Dave2e May 29 '20 at 19:07
  • 1
    that solve it, I could not found that. Thanks ! – Santiago I. Hurtado May 29 '20 at 19:10

1 Answers1

0

tbl_cube() was pulled out of dplyr and is now its own package called cubelyr.

You can install it with install.packages("cubelyr") and read the documentation here.

Hope this helps!

Mark
  • 7,785
  • 2
  • 14
  • 34