Hello,
I am getting the following error when using lobstr::obj_size or pryr::object_size with a ggplot object
Error in obj_size_(dots, env, size_node(), size_vector()) :
bad binding access
Here is a reprex
library(terra); library(ggplot2); library(tidyterra)
file_path <- system.file("extdata/cyl_temp.tif", package = "tidyterra")
temp_rast <- rast(file_path)
Plot <- ggplot() +
geom_spatraster(data = temp_rast, aes(fill = tavg_04)) +
coord_sf(crs = 3857) +
scale_fill_grass_c(palette = "celsius")
lobstr::obj_size(Plot) # this gives an error
object.size(Plot) # this works
# Without the `geom_spatraster` geometry, the function works
Plot <- ggplot() +
# geom_spatraster(data = temp_rast, aes(fill = tavg_04)) +
coord_sf(crs = 3857) +
scale_fill_grass_c(palette = "celsius")
lobstr::obj_size(Plot) # this works
It seems that the function can not read the file size of ggplot object when geom_spatraster is used.