knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Want to link up your data from different sources? Awesome! Just a heads-up, you'll probably need to do some cleaning first. Let's dive in and see how our package makes getting your SGIC data ready super easy.
We`ll start by loading trustmebro:
library(trustmebro)
Our key data set trustmebro::sailor_keys
is a longitudinal data set in long format. It is a tibble with r nrow(sailor_keys)
rows and r ncol(sailor_keys)
columns.
This data should be linked with our survey data trustmebro::sailor_students
, a tibble with r nrow(sailor_students)
rows and r ncol(sailor_students)
columns.
Let us take a quick look at the survey data:
print(trustmebro::sailor_students)
Yep, this data needs cleaning. There's a lot of unnecessary stuff, like whitespace. You see this all the time with survey data strings. We can replace all non-alphanumeric characters in string-variables of our data set trustmebro::sailor_students
using trustmebro::purge_string
:
purge_string(sailor_students, replacement = "#")
Please note that since we deal with data collected in Germany, umlauts remain unchanged from this.
A few variables need recoding for further analysis. For that, we can provide a recode map:
recode_map <- c(MALE = "M", FEMALE = "F")
The recode_map is a named vector where the names represent categories (in this case, "Male" and "Female"), and the values ("M" and "F") are the corresponding codes used for those categories. It is used to map full category labels to shorter, standardized values. We can pass it to trustmebro::recode_valinvec
, to recode the values accordingly. A new variable will be added that contains the recoded values
recode_valinvec(purge_string(sailor_students, replacement = "#"), gender, recode_map, gender_recode)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.