Reputation: 183
When trying to run pryr::object_size()
on a nested tibble or data frame, I receive the error below:
Error in obj_size_(dots, env, size_node(), size_vector()) :
bad binding access
Is this caused by having nesting in the data frames and/or tibbles? I cannot paste here exactly what I am working on, but here is a reproducible example:
library(data.table)
library(tidyverse)
library(pryr)
DT = data.table(x=c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100), y=c(10,30,66,75,81,101,135,143,181,210))
dt= data.frame(x=c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100), y=c(10,30,66,75,81,101,135,143,181,210))
testTabe <- function(dat){
tib <- data.table(
type = 'rate',
data = list(dat %>% mutate(
logX = log(x),
logY = log(y)
)
)
)%>% mutate(
model = tryCatch(lm(logY ~ logX, data=data[[1]]), error=function(cond) NA) %>% list()
)
return(tib)
}
testTib <- function(dat){
tib <- tibble(
type = 'rate',
data = list(dat %>% mutate(
logX = log(x),
logY = log(y)
)
)
)%>% mutate(
model = tryCatch(lm(logY ~ logX, data=data[[1]]), error=function(cond) NA) %>% list()
)
return(tib)
}
object_size(testTabe(DT))
object_size(testTib(DT))
From the above example specifically, I get the error on both object_size()
calls. Is this because they are nested? Is it something else? I've tried object_size()
on every unnested thing I could think of and it always works. Is there a workaround for this?
Upvotes: 1
Views: 37