Error when downloading data with R-Studio/Robotoolbox Package

Using an R-Script I have been able to download data from Kobotoolbox for several of my forms, however during the Processing stage for a few of them I get an error.

Error in `abort_table_not_in_dm()`:
! Table `NA` not in `dm` object. Available table names: `main`.
Run `rlang::last_trace()` to see where the error occurred.

The structure of the script is the same. Why would something be referencing a table called NA?

The same process has worked just fine on the majority of other forms made and produces a full set of data I can interact with. Has anyone using this system encountered this error before?

@peat, sharing this post, which should help you solve your issue cc: @dickoa:

The only example of that would be a decimal type column in one form which has a few minus numbers ‘-1’, ‘-2’, ‘-3’ and ‘-0.2’, but I don’t know if that would be a problem?

Some of the other forms which produce this error don’t actually have any data in them yet.

Hi @peat

Thanks for raising this issue. It might be related to a repeat_group, can you share a copy or minimal version of the xlsform. I need to reproduce the error to be able to fix it.

Thanks again

1 Like

Hi @dickoa, thankyou for your assistance with this! Happy to share the XLS form with you, unfortunately as a new user I am unable to upload files to this forum. I have just sent you the file via Wetransfer to the email you have listed on Github. If this isn’t going to work then please let me know how is best to get the file to you.

Thanks again!

1 Like

@peat, you should now be able to share your XLSForm through the community. Refresh your page if you are still not able to upload it.

Thanks, that seems to have worked!

eotb_form.xlsx (25.5 KB)

1 Like

Perfect, and also got it through my email. I’ll take a look, and I’ll come back to you.

2 Likes

@peat

I would love to understand better the project. I used your xlsform and added some data, and it works for me. For some reasons, I can’t reproduce it on my own.

image

I think there’s a repeat group created that we can’t access or something related to that. I’ll continue to see how to reproduce it but you have an idea or something that can help, please don’t hesitate.

1 Like

Hi @dickoa

Thanks for looking at this a while ago! I have come back to the issue as it is still unresolved.

I wanted to check to see if the script I am using to connect RStudio to Kobo is correct. It is what I have been using successfully to connect to my other working forms but wondered if this one needed something different? I noted in your code snippet that you reference ‘kobo_data(uid)’ which is not in my script at all!

This is what I am using -

#install.packages(“robotoolbox”)
library(robotoolbox) # KoboToolbox API
library(dplyr) # data wrangling
library(dm) # data modelling
library(labelled) # extract labels
library(janitor) # clean names
library(stringr) # string manipulation
library(tidyr) # data transformations

kobo_setup(url = “https://kf.kobotoolbox.org”,
token = “xxx”)

l ← kobo_asset_list()
l
form ← kobo_asset(‘xxx’)
dm ← kobo_submissions(form, all_versions = T, progress = T)
dm_draw(dm, rankdir = “RL”)

Hi @peat

kobo_data(uid) and kobo_data(kobo_asset(uid)) will you the same result. kobo_data and kobo_submissions are the same function too (alias).
I think the issue is elsewhere, I added few things on the dev version not specific to this issue, but you can try with the dev version

pak::pkg_install("dickoa/robotoolbox")

You can also try to read the latest version of the form only

...
dm <- kobo_submissions(form, all_versions = FALSE, progress = TRUE)
...
1 Like

Hi @dickoa

Thanks for the suggestions, I have (fingers-crossed), got this working now.

You’d suggested that Repeat sections of the form may be an issue so I removed them and the form worked. They were Repeat image submissions which I haven’t got in any of my other forms so I haven’t used this before.

I added ese back in one at a time and it continued to work. I did make one change though, one of these Repeat image questions was previously inside a group, it is now outside of that group and stands as its own question so perhaps that has made a difference?

Either way, it’s working now so I am happy! Until it breaks again anyway!

1 Like