I'm trying to import survey instances. The data.frame has all of the relevant data, but not the field variable names. It has the field ids instead. I notice the id_to_field_name argument defaults to NULL. I assume it can be used to retrieve the field variable names. In the source code, the id_to_field_name is a list with the indices as field ids (below is the code I'm referring to in CastorData.R, lines 421-428), but when comparing the field ids in the getSurveyInstancesBulk with the field ids in the getFields output, there's no overlap or identical field ids.
``
Get survey field ids and names to later clean up the split dataframes
I receive the error traceback below when I implement the above chunk.
Error in rename():
! All renaming inputs must be named.
Backtrace: 1. castor_api$getSurveyInstancesBulk(...) 2. dplyr::rename_at(...) 4. dplyr:::rename.data.frame(.tbl, !!!syms)
How can the field variable names be imported with the survey instances data? Is there a specific way to do so?
I'm trying to import survey instances. The data.frame has all of the relevant data, but not the field variable names. It has the field ids instead. I notice the id_to_field_name argument defaults to NULL. I assume it can be used to retrieve the field variable names. In the source code, the id_to_field_name is a list with the indices as field ids (below is the code I'm referring to in CastorData.R, lines 421-428), but when comparing the field ids in the getSurveyInstancesBulk with the field ids in the getFields output, there's no overlap or identical field ids.
``
Get survey field ids and names to later clean up the split dataframes
``
I also constructed an indexed list with field ids as indices and elements as field variable names, but to no avail (code below).
fields <- castor_api$getFields(study_id = "study id") voi_field_ids <- fields %>% filter(grepl("Variable of Interest", field_variable_name) & (grepl("Week", field_variable_name) | grepl("Month", field_variable_name))) %>% dplyr::select(field_id, field_variable_name) voi_field_ids_list <- voi_field_ids %>% as.list() voi_id_to_fieldname <- list() for (i in 1:dim(voi_field_ids)[1]){ field_id <- voi_field_ids_list[['field_id']][i] field_variable_name <- voi_field_ids_list[['field_variable_name']][i] voi_id_to_fieldname[[field_id]] <- field_variable_name } voi_id_to_fieldname castor_api$getSurveyInstancesBulk(study_id = "study id", id_to_field_name = voi_id_to_fieldname)
I receive the error traceback below when I implement the above chunk.
How can the field variable names be imported with the survey instances data? Is there a specific way to do so?