`expss` and `data.table` not playing well together

徘徊边缘 提交于 2019-12-24 12:03:38

问题


I am working with the expss package to produce banner tables for survey data, but I keep getting an error that doesn't come up a lot on Google: Error in data.table(cell_var, col_var, row_var) : object '.R.listCopiesNamed' not found.

I've created a reproducible example below. It's unclear to me if it's an error from expss or from data.table, or from the combination of the two. In any case there a way to override the need for '.R.listCopiesNamed', or some other way to resolve the error?

I'm working in this environment:
R version 3.4.4 (2018-03-15) -- "Someone to Lean On" Copyright (C) 2018 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin15.6.0 (64-bit)

Reproducible example:

# load packages
library(expss)
library(tidyverse)

# generate some data
set.seed(369)
age <- base::sample(c("18-24", "25-24", "35-44", "45-54", "55-64", "65+"), 
                    100, replace = TRUE)
sex <- base::sample(c("Male", "Female"), 
                    100, replace = TRUE)
likelihood <- base::sample(c("Much more likely", "Somewhat more likely", 
                             "Equally likely", "Somewhat less likely", 
                             "Much less likely"), 100, replace = TRUE)
importance <- base::sample(c("Extremely important", "Somewhat important", 
                             "Neutral", "Somewhat unimportant", 
                             "Extremely unimportant"), 100, replace = TRUE)
relevance <- base::sample(c("Extremely relevant", "Somewhat relevant", 
                            "Neutral", "Somewhat irrelevant", 
                            "Extremely irrelevant"), 100, replace = TRUE)
data <- data.frame(age, sex, likelihood, importance, relevance)

# make a simple banner table with significance testing
myTable <- data %>%
    tab_cells(likelihood, importance, relevance) %>%
    tab_cols(total(), age, sex) %>%
    tab_stat_cpct() %>%
    tab_last_sig_cpct() %>%
    tab_pivot()

At this point, I get the error:
Error in data.table(cell_var, col_var, row_var) : object '.R.listCopiesNamed' not found

~~~~~~~

Edited to add traceback() and sessionInfo():

> traceback()
19: data.table(cell_var, col_var, row_var)
18: make_datatable_for_cro(cell_var = cell_var, col_var = col_var, 
        row_var = row_var, weight = weight, subgroup = subgroup)
17: elementary_cro(cell_var = each_cell_var, col_var = each_col_var, 
        row_var = each_row_var, weight = weight, subgroup = subgroup, 
        total_label = total_label, total_statistic = total_statistic, 
        total_row_position = total_row_position, stat_type = stat_type)
16: FUN(X[[i]], ...)
15: lapply(col_vars, function(each_col_var) {
        elementary_cro(cell_var = each_cell_var, col_var = each_col_var, 
            row_var = each_row_var, weight = weight, subgroup = subgroup, 
            total_label = total_label, total_statistic = total_statistic, 
            total_row_position = total_row_position, stat_type = stat_type)
    })
14: FUN(X[[i]], ...)
13: lapply(cell_vars, function(each_cell_var) {
        all_col_vars = lapply(col_vars, function(each_col_var) {
            elementary_cro(cell_var = each_cell_var, col_var = each_col_var, 
                row_var = each_row_var, weight = weight, subgroup = subgroup, 
                total_label = total_label, total_statistic = total_statistic, 
                total_row_position = total_row_position, stat_type = stat_type)
        })
        Reduce(merge, all_col_vars)
    })
12: FUN(X[[i]], ...)
11: lapply(row_vars, function(each_row_var) {
        res = lapply(cell_vars, function(each_cell_var) {
            all_col_vars = lapply(col_vars, function(each_col_var) {
                elementary_cro(cell_var = each_cell_var, col_var = each_col_var, 
                    row_var = each_row_var, weight = weight, subgroup = subgroup, 
                    total_label = total_label, total_statistic = total_statistic, 
                    total_row_position = total_row_position, stat_type = stat_type)
            })
            Reduce(merge, all_col_vars)
        })
        res = do.call(add_rows, res)
    })
10: multi_cro(cell_vars = cell_vars, col_vars = col_vars, row_vars = row_vars, 
        weight = weight, subgroup = subgroup, total_label = total_label, 
        total_statistic = total_statistic, total_row_position = total_row_position, 
        stat_type = "cpct")
9: cro_cpct(cell_vars = get_cells(data), col_vars = data[[COL_VAR]], 
       row_vars = data[[ROW_VAR]], weight = data[[WEIGHT]], subgroup = 
data[[SUBGROUP]], 
       total_label = total_label, total_statistic = total_statistic, 
       total_row_position = total_row_position)
8: tab_stat_cpct(.)
7: function_list[[i]](value)
6: freduce(value, `_function_list`)
5: `_fseq`(`_lhs`)
4: eval(quote(`_fseq`(`_lhs`)), env, env)
3: eval(quote(`_fseq`(`_lhs`)), env, env)
2: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
1: data %>% tab_cells(likelihood, importance, relevance) %>% tab_cols(total(), 
       age, sex) %>% tab_stat_cpct() %>% tab_last_sig_cpct() %>% 
       tab_pivot()


> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib

LAPACK: 
/Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] expss_0.8.6

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17       matrixStats_0.53.1 digest_0.6.15      backports_1.1.2   
 [5] magrittr_1.5       stringi_1.1.6      data.table_1.11.4  rstudioapi_0.7    
 [9] checkmate_1.8.5    tools_3.4.4        stringr_1.3.0      foreign_0.8-69    
[13] htmlwidgets_1.2    yaml_2.1.17        compiler_3.4.4     htmltools_0.3.6   
[17] knitr_1.20         htmlTable_1.11.2

回答1:


The solution: Update the expss package. Thanks to @MichaelChirico for the suggestion!



来源:https://stackoverflow.com/questions/51084894/expss-and-data-table-not-playing-well-together

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!