Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in set_label.default(x[[nm]], lab) #27

Closed
sdwfrost opened this issue Jan 29, 2021 · 21 comments
Closed

Error in set_label.default(x[[nm]], lab) #27

sdwfrost opened this issue Jan 29, 2021 · 21 comments

Comments

@sdwfrost
Copy link

Hi @nutterb

This is repeat of the error from issue 158:

Error in set_label.default(x[[nm]], lab) : 
  labels may not be added to `NULL` objects.

I tried to install the issue-158 branch, but it doesn't seem to print out the variables. I'm using the latest version:

> xfun::session_info('redcapAPI')
R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Locale:
  LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
  LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
  LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
  LC_PAPER=en_US.UTF-8       LC_NAME=C                 
  LC_ADDRESS=C               LC_TELEPHONE=C            
  LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

Package version:
  askpass_1.1       assertthat_0.2.1  backports_1.2.1   BH_1.75.0.0      
  checkmate_2.0.0   chron_2.3.56      cli_2.2.0         clipr_0.7.1      
  cpp11_0.2.6       crayon_1.3.4      curl_4.3          DBI_1.1.1        
  digest_0.6.27     dplyr_1.0.3       ellipsis_0.3.1    fansi_0.4.2      
  generics_0.1.0    glue_1.4.2        graphics_4.0.0    grDevices_4.0.0  
  hms_1.0.0         httr_1.4.2        jsonlite_1.7.2    labelVector_0.1.1
  lifecycle_0.2.0   lubridate_1.7.9.2 magrittr_2.0.1    methods_4.0.0    
  mime_0.9          openssl_1.4.3     pillar_1.4.7      pkgconfig_2.0.3  
  purrr_0.3.4       R6_2.5.0          Rcpp_1.0.6        readr_1.4.0      
  redcapAPI_2.3.1   rlang_0.4.10      stats_4.0.0       stringi_1.5.3    
  stringr_1.4.0     sys_3.4           tibble_3.0.6      tidyr_1.1.2      
  tidyselect_1.1.0  tools_4.0.0       utf8_1.1.4        utils_4.0.0      
  vctrs_0.3.6      
@peterolejua
Copy link

peterolejua commented Feb 16, 2021

Hello,

I'm trying to export these data and an error occurs when I uncomment any of the three fields below:

data <- exportRecords( rcon, fields = c( "numero_encuesta", "fecha_creac_redcap", "codigo_estudio", "laboratorio", "investigador_principal", "farmaco", "patologia_estudio", "pais", "edad", "sexo", "fecha_inicio", "caracte_seriedad", "numero_evento_seguimiento", "seguimiento", # "nombre_evento", "sistema", "relacion_farmaco", "clasif_evento_manual", "med_concomitante", # "concomitantes", # "comorbilidades", "observaciones", "pdf" ) )

Error:
not all columns named in 'colClasses' existError in set_label.default(x[[nm]], lab) : labels may not be added toNULLobjects.

Traceback:
7. stop("labels may not be added toNULL` objects.")

  1. set_label.default(x[[nm]], lab)

  2. labelVector::set_label(x[[nm]], lab)

  3. (function (nm, lab) { labelVector::set_label(x[[nm]], lab) })(nm = dots[[1L]][[1L]], lab = dots[[2L]][[1L]])

  4. mapply(nm = suffixed$name_suffix, lab = suffixed$label_suffix, FUN = function(nm, lab) { labelVector::set_label(x[[nm]], lab) }, SIMPLIFY = FALSE)

  5. exportRecords.redcapApiConnection(rcon, fields = c("numero_encuesta", "fecha_creac_redcap", "codigo_estudio", "laboratorio", "investigador_principal", "farmaco", "patologia_estudio", "pais", "edad", "sexo", "fecha_inicio", "caracte_seriedad", "numero_evento_seguimiento", "seguimiento", ...

  6. exportRecords(rcon, fields = c("numero_encuesta", "fecha_creac_redcap", "codigo_estudio", "laboratorio", "investigador_principal", "farmaco", "patologia_estudio", "pais", "edad", "sexo", "fecha_inicio", "caracte_seriedad", "numero_evento_seguimiento", "seguimiento", ...

    REDCap 10.7.1 - © 2021 Vanderbilt University

sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS: /usr/lib/libblas.so.3.9.0
LAPACK: /usr/lib/liblapack.so.3.9.0

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

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

other attached packages:
[1] redcapAPI_2.3 DT_0.17 splitstackshape_1.4.8 lubridate_1.7.9.2 kableExtra_1.3.2 knitr_1.31 summarytools_0.9.8
[8] ggExtra_0.9 ggplot2_3.3.3 labelled_2.7.0 tibble_3.0.6 tidyr_1.1.2 dplyr_1.0.4 readxl_1.3.1

loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 digest_0.6.27 mime_0.10 chron_2.3-56 R6_2.5.0 cellranger_1.1.0 plyr_1.8.6 backports_1.2.1
[9] evaluate_0.14 httr_1.4.2 pillar_1.4.7 rlang_0.4.10 curl_4.3 data.table_1.13.6 rstudioapi_0.13 miniUI_0.1.1.1
[17] magick_2.6.0 checkmate_2.0.0 rmarkdown_2.6 webshot_0.5.2 stringr_1.4.0 pander_0.6.3 htmlwidgets_1.5.3 munsell_0.5.0
[25] tinytex_0.29 shiny_1.6.0 compiler_4.0.4 httpuv_1.5.5 xfun_0.21 pkgconfig_2.0.3 base64enc_0.1-3 htmltools_0.5.1.1
[33] tcltk_4.0.4 tidyselect_1.1.0 codetools_0.2-18 matrixStats_0.58.0 viridisLite_0.3.0 crayon_1.4.1 withr_2.4.1 later_1.1.0.1
[41] grid_4.0.4 xtable_1.8-4 gtable_0.3.0 lifecycle_0.2.0 magrittr_2.0.1 scales_1.1.1 stringi_1.5.3 pryr_0.1.4
[49] promises_1.2.0.1 xml2_1.3.2 ellipsis_0.3.1 rapportools_1.0 generics_0.1.0 vctrs_0.3.6 tools_4.0.4 forcats_0.5.1
[57] glue_1.4.2 purrr_0.3.4 hms_1.0.0 fastmap_1.1.0 yaml_2.2.1 colorspace_2.0-0 rvest_0.3.6 labelVector_0.1.1
[65] haven_2.3.1
`

@peterolejua
Copy link

I did devtools::install_github("nutterb/redcapAPI") (the master branch) to install 2.3.1. Same error.

@peterolejua
Copy link

Has anybody found a solution?

@peterolejua
Copy link

@nutterb ?

@peterolejua
Copy link

It seems to be a problem with some utf-8 characters (ex. in a surname: "ESTUPI�AN"). These were characters that were imported to that project from excel. How can I set the encoding to UTF-8?

@peterolejua
Copy link

I can do this and it works:

formData <- list(
  "token"=token,
  content='record',
  format='csv',
  type='flat',
  csvDelimiter='',
  rawOrLabel='label',
  rawOrLabelHeaders='label',
  exportCheckboxLabel='true',
  exportSurveyFields='false',
  exportDataAccessGroups='false',
  returnFormat='csv'
)
response <- httr::POST(url, body = formData, encode = "form")
result <- httr::content(response, encoding="UTF-8")

@peterolejua
Copy link

I can't figure out how to do it with exportRecords or redcapConnection

@wibeasley
Copy link

@nutterb, I vaguely remember this problem with OuhscBbmc/REDCapR#270.

@nutterb
Copy link
Owner

nutterb commented Apr 23, 2021

I've been working on getting access to REDCap again. I got access a couple of weeks ago, but am just now getting to using it.

I haven't tried this myself yet, but I'm about to try now. I wonder if doing the following might help:

library(redcapAPI)
rcon <- redcapConnection(url = '[your_url]',
                         token = '[your_token]',
                         config = list(encoding = 'UTF-8'))

@neurodoclove
Copy link

Just to jump on here and say I'm experiencing similar issues -- adding the config=list(encoding= 'UTF-8')) did not resolve the problem.

@neurodoclove
Copy link

FYI -- we found we do not get this error if we set labels=FALSE when using exportRecords.

@RaymondBalise
Copy link

RaymondBalise commented Jun 13, 2021

Thank you @neurodoclove! That workaround was a gift....

@graywh
Copy link

graywh commented Oct 15, 2021

I'm getting this error when the content from REDCap does not include a requested field.

@spgarbet
Copy link
Collaborator

spgarbet commented Nov 6, 2021

I'm getting this error now as well. Several collaborators are reporting it as well. We are using REDCap 11.4.3.

@nbarrowman
Copy link

We are using REDCap version 10.5.1 and we recently experienced this error in two different situations. One was due to a checkbox field that had no items. (I had to dig into the code in the redcapAPI package to identify the problem.) A second was due to not having appropriate permissions to access all fields.

@BdR76
Copy link

BdR76 commented Feb 1, 2023

(EDIT: nevermind, in this comment I was using redcapAPI v2.3 which is an old version of the library)

I also got this error in Redcap v12.4.6 and adding labels=FALSE fixes it, thanks @neurodoclove

I'll just add that it only happened in 2 of the 14 instruments and those instruments both have radio and checkbox fields with some non-standard looking choices, the first looks like this:

"What period of pregnancy" = Checkboxes (Multiple Answers)

Choices (one choice per line):
-1, Within 3 month of pregnancy
1, 1<sup>st</sup>, 2<sup>nd</sup>, 3<sup>rd</sup> month of pregnancy
2, 4<sup>th</sup>, 5<sup>th</sup>, 6<sup>th</sup> month of pregnancy
3, 7<sup>th</sup>, 8<sup>th</sup>, 9<sup>th</sup> month of pregnancy

and the other one:

"ICD code" = Multiple Choice Drop-down List (Single Answer) 
* Has more than 5000 choices and "Enable auto-complete", user didn't want to use the bioportal for some reason(?)

Choices (one choice per line):
_K_, %K% retrognatia
005, 005 Food poisoning
135, 135 Sarcoidosis 
.. etc ..
Z733, Z733 Stress other
Z910, Z910 Allergy to milk products

So I suspect it might have to do with either the negative answer code -1 or the _K_, %K% retrognatia option, or else the html codes <sup>th</sup> in the answer labels.

@BdR76
Copy link

BdR76 commented Feb 1, 2023

I just checked sessionInfo() in the Rstudio console, and under "other attached packages" I saw that we were using redcapAPI v2.3 which is an older version of the library.

After running install.packages("redcapAPI") again to update to 2.3.3 the issue was also fixed without the use of the labels=FALSE parameter.

@spgarbet
Copy link
Collaborator

I think pull request nutterb/redcapAPI#190 fixed this.

@spgarbet
Copy link
Collaborator

I'm curious about the html. I've seen others report that html in fields causes crashes. It's on my list of things to poke at.

@nutterb nutterb transferred this issue from nutterb/redcapAPI-Defunct Mar 21, 2023
@nutterb
Copy link
Owner

nutterb commented Mar 21, 2023

vubiostat#24 may be relevant.

@nutterb
Copy link
Owner

nutterb commented Apr 10, 2023

redcap 2.7.0 (vubiostat#70) add exportRecordsTyped, which is what is being recommended over exportRecords.

Please see https://github.com/vubiostat/redcapAPI

this new function addresses HTML and UNICODE characters better than I ever did.

@nutterb nutterb closed this as completed Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants