Description
This function will create a reference to records on the server. For large forms, this does not immediately transfer all records; you can use the dplyr::filter , dplyr::arrange , dplyr::slice_head , dplyr::slice_tail , and/or adjustWindow functions to narrow the the selection of records.
To prevent downloading the records before making a selection use the verbs in this order.
-
dplyr::arrange (limited to a single column) and/or dplyr::filter in any combination
-
dplyr::slice_head or adjustWindow in any combination
Usage
getRecords(form, style)
Arguments
Argument | Description |
---|---|
form |
a form id, form schema, form tree, or activity info data frame |
style |
a column style object that defines how table columns should be created from a form; use columnStyle to create a new style; default column styles can be set with an option or defaultColumnStyle . Default columnNames is set to "pretty". |
Examples
# Retrieve all the records from the Simple 3W template's project form:
# https://www.activityinfo.org/app#form/ceam1x8kq6ikcujg/table
records <- getRecords("ceam1x8kq6ikcujg")
# Now, filter by only projects with a status "Under implementation"
records <- getRecords("ceam1x8kq6ikcujg") %>%
filter(`Project status` == "Under implementation")
# If you want to use the field codes, set the column style using the `columnStyle()`
# function and setting `columnName` argument to 'code'.
# You can then use the field code in your filter:
records <- getRecords("ceam1x8kq6ikcujg", style = columnStyle(columnNames = "code")) %>%
filter(START_MONTH == "2018-01")
# If you prefer to work with the ActivityInfo field IDs, then you can change
# the column style and the `columnNames` argument to "id":
records <- getRecords("ceam1x8kq6ikcujg", style = columnStyle(columnNames = "id")) %>%
filter(cgkh1k5kq6k0gsmv == "2018-01")