Introducing the R package robotoolbox

Great work @dickoa, congrats! This package help me a lot.

3 Likes

Quick question… When importing data using kobo_data(), is there a way to specify that a specific variable should be imported as a character and not numeric? I ask because, in my data, I have a question where I ask my enumerators to report questions not answered by respondents and to separate those numbers by commas (,). So for example, if the respondent did not answer questions 2,3 and 4, the entry for this question would be (2,3,4). However, in the import, kobo_data() interprets this as a numeric question and drops the commas (,) so that in the import, this shows as 234.

1 Like

Hi @fodhiambo,

That’s an interesting use case, let me see what can be done. The data is pulled from the API in json format and then parsed into a data.frame in R. I’ll see if during the JSON to data.frame we can allow certain data to be as character.
I’ll need a minimal form to reproduce the behavior to work on a fix. I’ll come back to you ASAP

1 Like

@dickoa, of course. Let me know how I can be of help on this. I am a new user(just newly registered :slight_smile:) , so cannot upload an xls form. But you can download here >>> xls_form.xlsx - Google Sheets

Can you try the dev version and tell me if it works as expected now ?

# install.packages("pak")
pak::pkg_install("dickoa/robotoolbox")

Don’t forget to restart your session with the new version of robotoolbox.

1 Like

@dickoa, thanks for this update; the import behaves as expected now. Once again, thank you so much

2 Likes

Thanks @fodhiambo for raising this issue, it’ll make the package more robust.

3 Likes

Many thanks for this very useful package.
Are you planning a function to post via API .csv file(s) to the ā€˜media’ folder where Kobotoolbox stores data that is used in the survey form ā€œpulldataā€ function?
Thanks for considering. Xavier

Thanks Xavier, in the dev version I started working on pull media files. I’ll see if I can add a function to push too. You’re the second person to ask this feature. I’ll see what I can do and thanks for feedback.

Best,
Ahmadou

2 Likes

Many thanks for this. If you need someone to test the code I will be happy to do so.

With kind regards, Xavier

1 Like

@dickoa I was wondering if it is possible to delete downloaded attachments from the Kobo server to free up storage?

Hi @guido167
The package was designed to just pull data from the server, not really push/manage.
It’s not the first time I receive this request, I’ll see if it’s possible to add a function to delete attachments, subs, etc.

2 Likes

hello @dickoa , for some reason…when i pull data from the server, i noticed that the ā€œ_submission__uuidā€ is omitted/missing in the repeat groups.

also the forward slash ā€œ/ā€ is replaced by underscores ā€œ_ā€ i want this to be replaced by period ā€œ.ā€ is there a workaround

thanks

Hi @morriz,

I’ll check for the missing submission_uuid in the repeat groups, and fix it if I can reproduce it.
I already provide the option to pick a separator for select multiple questions, I’ll see if I can easily do the same for the group separator too.
Ahmadou

2 Likes

sorry if this has already been asked, but can you point me to where the separator is.? or how its done

Hi @morriz,
This is a separator for the select multiple, not for the group as you want. For the select multiple questions, you have a select_multiple_sep parameter in kobo_data (kobo_submission).

1 Like

Hi @dickoa after using the kobo_attachment_download function a bit more and basing a lot of my script on it, I notice that somehow it downloads the attachments wrong. When I view my submissions in the table view on the KoboToolbox platform I see which image was uploaded as part of a submission (see top image). When I compare that filename with the image that is in the download folder given in the kobo_attachment_download() it is a completely different image…!

The id added by the kobo_attachment_download() at the start of the filename refers to the correct submission with the correct image.

Could you please check as this messes up our database quite considerably. Thank you! :slight_smile:

@dickoa after rerunning the code again the downloaded image under this filename has changed to another image, but it is still the wrong one. Seems to download random images under the filenames in the submission fields.

Thanks for reporting this issue @guido167, and sorry for the inconvenience. I’ll first try to reproduce this issue and then fix it.
Ahmadou

2 Likes

Thank you @dickoa that would be great. Hope you (or anyone else) can help me with the following: is there a way to generate a link to edit a submission on the Kobo website from R? I am exporting xlsx files and want to have a column that contains a link to edit a record directly (instead of having to look it up in the table). Not sure if this is easy to do?