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

redcap_read() Error in inherits(ds, "data.frame") : object 'ds' not found #8

Open
dlemas opened this issue Feb 22, 2020 · 3 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@dlemas
Copy link
Collaborator

dlemas commented Feb 22, 2020

I am trying to create a script that queries physical activity data in BEACH redcap project. When I called the data using redcap_read()- I received the following error:

redcap_read() Error in inherits(ds, "data.frame") : object 'ds' not found

does this happen for anyone else? I have tried several scripts.

BEACH>reports>data_inventory.Rmd

@dlemas dlemas added the bug Something isn't working label Feb 22, 2020
@XinsongDu
Copy link
Member

XinsongDu commented Feb 22, 2020

Greetings Dr. Lemas:

I tried the code just now, and I was able to pull the data without the error if I changed the "ds" to "dat". I think the error might be because "ds" has never been defined as a variable in the code? Following is part of my code:

> # Create connections
> rcon <- redcapConnection(url=uri, token=beach_token)
> desired_fields=c("test_id","redcap_event_name",
+                  "beach_part_drop_out",
+                  "mompa_todays_date","mompa_study_visit",
+                  "mompa_walk_slow","mompa_walk_quick",
+                  "mompa_walk_hills","mompa_jog",
+                  "mompa_prenatal_exer","mompa_swim",
+                  "mompa_dance","mompa_other_exer")
> desired_fields=c("test_id","redcap_event_name",
+                  "beach_part_drop_out",
+                  "mompa_todays_date","mompa_study_visit",
+                  "mompa_walk_slow","mompa_walk_quick",
+                  "mompa_walk_hills","mompa_jog",
+                  "mompa_prenatal_exer","mompa_swim",
+                  "mompa_dance","mompa_other_exer")
> dropped.records.v1=c("BLS006A",
+                      "BLS010A",
+                      "BLS015A",
+                      "BLS026A",
+                      "BLS029A",
+                      "BLS037A",
+                      "BLS039A",
+                      "BLS050A",
+                      "BLS054A")
> dat<- redcap_read(
+     batch_size=300,
+     records= dropped.records.v1,
+     redcap_uri = uri, 
+     token      = beach_token, 
+     fields     = desired_fields
+ )$data
> head(dat)
  test_id     redcap_event_name redcap_repeat_instrument redcap_repeat_instance beach_part_drop_out mompa_study_visit mompa_walk_slow mompa_walk_quick
1 BLS006A        baseline_arm_1                       NA                     NA                   1                NA              NA               NA
2 BLS006A third_trimester_arm_1                       NA                     NA                   1                 1               2                2
3 BLS010A        baseline_arm_1                       NA                     NA                   1                NA              NA               NA
4 BLS010A third_trimester_arm_1                       NA                     NA                   0                 1               6                2
5 BLS010A        two_week_arm_1                       NA                     NA                  NA                 2               2                2
6 BLS010A       two_month_arm_1                       NA                     NA                  NA                 3               3                2
  mompa_walk_hills mompa_jog mompa_prenatal_exer mompa_swim mompa_dance
1               NA        NA                  NA         NA          NA
2                2         1                   1          1           1
3               NA        NA                  NA         NA          NA
4                1         1                   1         NA           1
5                1         1                   2          1           1
6                1         1                   1          1           1
> inherits(dat, "data.frame")
[1] TRUE

@luran1
Copy link
Contributor

luran1 commented Feb 23, 2020

that happens to me sometimes, A workaround is declaring an empty data frame with the same variable name before the redcap_read().

@ChemiKyle
Copy link

Hi guys! Not sure if this issue is still causing you trouble, but we (UF CTS-IT) came across this issue in a project we're running and traced the problem to non-UTF-8 characters in the section headers for the REDCap project we were reading data from.

redcap_read crashes along the way because the rogue character upsets the redcap_read_metadata function (which is not used in redcap_read_oneshot, so that still works, so it'd be a useful litmus test for the metadata failure cascade).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants