0

I've been using the REDCapR package to read in data from my survey form. I was reading in the data with no issue using redcap_read until I realized I needed to add a field restriction to one question on my survey. Initially it was a short answer field asking users how many of something they had, and people were doing expectedly annoying things like spelling out numbers or entering "a few" instead of a number. But all of that data read in fine. I changed the field to be a short answer field (same type as before) that requires the response to be an integer and now the data won't read into R using redcap_read.

When I run:

redcap_read(redcap_uri=uri, token=api_token)$data

I get the error message that:

Column [name of my column] can't be converted from numeric to character

I also noticed when I looked at the data that that it read in the 1st and 6th records of that column (both zeros) just fine (out of 800+ records), but everything else is NA. Is there an inherent problem with trying to read in data from a text field restricted to an integer or is there another way to do this?

Edit: it also reads the dates fine, which are text fields with a date field restriction. This seems to be very specific to reading in the validated numbers from the text field.

I also tried redcapAPI::exportRecords and it will continue to read in the rest of the dataset, but reads in NA for all values in the column with the test restriction.

4

1 回答 1

0

将REDCapR升级到 GitHub 上的版本,在确定数据类型之前将批次堆叠在一起(参见#257)。

# install.packages("remotes") # Run this line if the 'remotes' package isn't installed already.
remotes::install_github(repo="OuhscBbmc/REDCapR")

在您的情况下,我相信批次(默认情况下为 200 条记录)包含不同的不同数据类型(字符和数字,根据错误消息),它们不会默默地堆叠在一起。

REDCapR::redcap_read()功能应该可以工作。(如果没有,请创建一个新问题)。

两种选择是

  1. 调用 redcap_read_oneshot,guess_max
  2. redcap_read_oneshot用调用 guess_type = TRUE
于 2020-01-18T16:59:26.160 回答