knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of SurveyExactDataImporter is to simplify loading of data from the online questionaire system SurveyExact.
You can install the development version of SurveyExactDataImporter from github with:
library(devtools) install_github("henrikmidtiby/SurveyExactDataImporter")
Load libraries
library(SurveyExactDataImporter) library(ggplot2)
Load example dataset.
data <- load_survey_exact_data("data/dataset_1488637_20180512_1825827966544069436.xlsx")
Show a summary of the imported data. Note that the factor levels are sorted as specified in SurveyExact and not alphabetically as otherwise is the standard approach (what else to to when it is not specified ...).
summary(data$data)
Extract information about a certain element in the questionaire.
get_variable_name(data, 's_6') get_variable_name_category(data, 's_6') get_variable_name_subcategory(data, 's_6')
Show distribution of answers to a single question (s_6).
ggplot(data$data) + geom_bar(aes(s_6)) + scale_x_discrete(drop=FALSE) + coord_flip() + labs(subtitle = get_variable_name(data, 's_6'), x = "")
Make a scatter plot of answers to two questions (s_6 and s_7).
ggplot(data$data) + geom_count(aes(s_6, s_7)) + scale_x_discrete(drop=FALSE) + scale_y_discrete(drop=FALSE) + coord_flip() + labs(title = get_variable_name_category(data, 's_6'), x = get_variable_name_subcategory(data, 's_6'), y = get_variable_name_subcategory(data, 's_7')) + theme(axis.text.x = element_text(angle = 30, hjust = 1, vjust = 1), axis.text.y = element_text(angle = 30, hjust = 1, vjust = 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.