knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library("koboloops")
Here we create some fake data for illustration purposes. It is not important to understand this; we keep it in so you can run the example yourself if you like. There are two datasets.
The parent one contains:
uuid
: values must be uniqueage
: values between 30 and 60parent_gender
The child contains:
parent_uuid
: should be number among the uuid of the parent datasetage
: values between 1 and 18child_gender
just some numbers, but the column header indicates this is potentially sensitiveparent <- data.frame(uuid=1:10, age_parent=sample(30:60,10,replace = T),parent_gender=sample(c("F","M"),10,replace = T)) child <- data.frame(parent_uuid=sample(1:10,20,replace = T), age_child=sample(1:18,20,replace=T), child_gender=sample(c("F","M"),20,replace = T))
family <- add_parent_to_loop(child,parent,uuid.name.loop = "parent_uuid",uuid.name.parent = "uuid",c("age_parent")) family
run ?add_parent_to_loop
for details.
We affect to the parent the average ages of the children.
variable.to.add = c(mean_of_child_age="age_child")
family <- affect_loop_to_parent(child, parent,aggregate.function = mean , variable.to.add) family
run ?affect_loop_to_parent
for details.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.