Skip to content

upgrade_dfm() not working on some pre-docid_ v2 objects #2097

Description

@chainsawriot

Describe the bug

I encounter this problem while working with the useNews (@cbpuschmann & @MarHai, 2020) dataset. As the data is not from me, it could be a data issue (e.g. the dfm is malformed). But displaying the dataset doesn't suggest so.

I can't directly pinpoint what is the actual cause of the error. debug() actually points to dfm_match, exactly this line.

Reproducible code

Please paste minimal code that reproduces the bug. If possible, please upload the data file as .rds.

require(osfr)
require(quanteda)

osf_retrieve_node("uzca3") %>% osf_ls_files(n_max = 1, pattern = "usenews.mediacloud.wm.RData") %>% osf_download(path = ".", progress = TRUE)

load("usenews.mediacloud.wm.RData")

## mediacloud.wordmatrix2019 and mediacloud.wordmatrix2020 are a list of dfms.

mediacloud.wordmatrix2019[[1]] ## looks okay, it was created with v 1.5.2
mediacloud.wordmatrix2020[[1]] ## this one might be corrupted, but looks okay, was created with v 2.1.0 

dfm_lookup(mediacloud.wordmatrix2019[[1]], dictionary(list(Boston = c("boston")))) ## works
dfm_match(mediacloud.wordmatrix2019[[1]], "boston") ## works

dfm_lookup(mediacloud.wordmatrix2020[[1]], dictionary(list(Boston = c("boston")))) ## error
dfm_match(mediacloud.wordmatrix2020[[1]], "boston") ## print problem

Expected behavior

It works for 2019 data but not for 2020 data. 2020 data should work.

System information

R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] quanteda_3.0.0 osfr_0.2.8    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6         magrittr_2.0.1     stopwords_2.2      tidyselect_1.1.0  
 [5] lattice_0.20-41    R6_2.5.0           rlang_0.4.10       fastmatch_1.1-0   
 [9] httr_1.4.2         dplyr_1.0.2        tools_4.0.4        grid_4.0.4        
[13] ellipsis_0.3.1     RcppParallel_5.0.3 digest_0.6.27      httpcode_0.3.0    
[17] tibble_3.0.4       lifecycle_0.2.0    crayon_1.4.1       Matrix_1.3-2      
[21] purrr_0.3.4        vctrs_0.3.5        fs_1.5.0           curl_4.3          
[25] crul_1.0.0         memoise_1.1.0      glue_1.4.2         stringi_1.5.3     
[29] compiler_4.0.4     pillar_1.4.7       generics_0.1.0     jsonlite_1.7.1    
[33] pkgconfig_2.0.3   

Additional info

Both the CRAN version (2.1.2) and the Github version (3.0.0) have the same issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions