View source: R/pt_nest_attachments.R
pt_nest_attachments | R Documentation |
Nests attachment columns obtained when reading structured data from the kobo landings survey
pt_nest_attachments(x)
x |
A data frame containing raw landings data from the Timor operations. |
One of the disadvantages of using structured survey data is that the tables can become very wide (many columns). This happens when question groups or other fields can be recorded multiple times. For example in the landings survey, for each species captured, about 17 questions are recorded. There is no limit to the number of species that can be recorded in the trip. If, for example a survey records seven species we will have over a hundred columns in the data corresponding to species information.
To improve that situation an avoid using multiple tables we use nested data frames (see tidyr::nest). In nested data frames columns can be lists and can contain arbitrary information, like other data frames, lists, vectors, or models.
Landings data in which the information about multiple attachments has
been nested into a single column (_attachments
) this column contains a
tibble for every row. This, attachment tibble has as many rows as there are
attachments.
dummy_landings <- tidyr::tibble(
`_id` = "123",
`_attachments.0.download_url` = "http://url-1.com",
`_attachments.0.id` = "01",
`_attachments.1.download_url` = "http://url-2.com",
`_attachments.1.id` = "02",
`_attachments.2.download_url` = NA,
`_attachments.2.id` = NA
)
pt_nest_attachments(dummy_landings)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.