Description Usage Arguments Details Value Note Examples
load.svy
takes a data file and a metadata file and returns a svy
object.
1 2 |
data |
a filename containing the survey data in csv format |
form |
a filename containing the survey metadata in json format |
update.fun |
an optional function to modify the raw data |
The data file is read into a data frame. Then the optional update.fun is run on the data.frame to incorporate post-collection corrections or updates. This function should not add choices or make any other changes to the meta data or the attributes of the data.frame or its columns. It should simply take the data.frame as its only argument and return the updated data.frame in the same format, as if it had just been read from file.
The metadata file is parsed into a list using fromJSON
and
the questions are extracted recursively using extract
on the top level
children
element. For each question, data is retrieved from the
corresponding column(s) of the data.frame and appended to the survey, and
the metadata is appended to the data's attributes (see svq
).
The data is either a vector or a matrix, depending on the question
type (see extract
)
Finally the elements of metadata list (except children
) are appended
to the attributes of the resultant data.frame
an object of class svy inheriting from data.frame, where each column is an object of class svq of a type appropriate to the question type
The default parameters of this function are meant to function with formhub file naming conventions.
1 2 3 4 | ## Not run:
load.svy("mysurvey_2015_05_01_05_31_27.csv")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.