尝试pryr::object_size()
在嵌套的 tibble 或数据框上运行时,我收到以下错误:
Error in obj_size_(dots, env, size_node(), size_vector()) :
bad binding access
这是由嵌套在数据框和/或小标题中引起的吗?我无法准确地将我正在处理的内容粘贴到此处,但这是一个可重现的示例:
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))
object_size()
具体来说,从上面的示例中,我在两个调用中都得到了错误。这是因为它们是嵌套的吗?是别的吗?我已经尝试object_size()
了所有我能想到的未嵌套的东西,它总是有效的。有解决方法吗?