Learn R Programming

occupationMeasurement

A toolbox to help you with all tasks around the coding and measurement of occupations.

[online demo[^1]]

[^1]: Demo for questionnaire_demo() running on shinyapps.io. Alternative demos for questionnaire_web_survey() [demo] and questionnaire_interviewer_administered() [demo] are also available. Demos may be unavailable due to bandwidth restrictions.

About

Coding people's occupations into official classifications such as the International Standard Classification of Occupations ISCO-08 or German KldB-2010 is a notoriously difficult problem. This toolbox is designed to make this easier, by helping with many of the tasks surrounding the measurement of occupations: From creating a survey and collecting data all the way to retrieving the final coded responses.

For a detailed overview of the package refer to vignette("occupationMeasurement") or take a look at browseVignettes("occupationMeasurement") to see a list of vignettes describing the package. All vignettes are also available in the online documentation.

Please cite our publication when using the software:

Jan Simson, Olga Kononykhina, and Malte Schierholz (2023). occupationMeasurement: A Comprehensive Toolbox for Interactive Occupation Coding in Surveys. Journal of Open Source Software, 8(88), 5505, https://doi.org/10.21105/joss.05505

Installation

Prerequisites:

The package can be installed directly from CRAN by running the code below:

install.packages("occupationMeasurement")

To install the latest development version from GitHub, run you will need the R package remotes available via install.packages("remotes").

The package can then be installed by running the code below:

remotes::install_github("occupationMeasurement/occupationMeasurement")

Usage

Using the interactive App

The interactive app is the easiest way to use the package: It provides a fully-featured, interactive survey application to collect and immediately code occupational data. Starting it is as easy as calling the app()-function.

More information about the interactive app can be found in vignette("app") and the help page ?app.

# Run the interactive shiny app
occupationMeasurement::app()

The app also supports custom questionnaires, so you can build your own or use and adapt one of the questionnaires included in the package. E.g., the questionnaire_demo() will explain the functionality of the app, and questionnaire_interviewer_administered() is designed to be read by interviewers in CATI and CAPI surveys. The questionnaire_web_survey() is intended to be used for internet surveys.

library(occupationMeasurement)

# Run the app with additional explanations. The best way to get started.
app(questionnaire = questionnaire_demo())

# Run the app in interviewer-administered ...
app(questionnaire = questionnaire_interviewer_administered())
# or online surveys
app(questionnaire = questionnaire_web_survey())

Alternative Usage

Besides the interactive app, there are also two alternative ways of using this package, with varying degrees of flexibility and convenience:

  1. Use the included JSON api() to use the package with your own survey-tool or application for maximum flexibility.
  2. Use the R functions directly to implement your own custom functionality or package via e.g. get_job_suggestions().

You can find more information on how to use these functionalities in vignette("occupationMeasurement").

Getting Help & Contributing

If you encounter any issues / bugs in the package, feel free to file an issue on GitHub, ideally alongside a clear reproducible example or description.

We also welcome contributions to the package. If you want to contribute to the development of the package, we recommend to first open an issue to discuss your ideas and plans, before working on a pull request.

If you have any questions about the package or plan to use it in a project, feel free to reach out to one of the maintainers via email. The list of maintainers and their email addresses is in the DESCRIPTION file.

Package Development

This section is only relevant when further developing the package itself.

By default the package will only install dependencies it absolutely needs to run. For developing the package or running tests, the following packages can be installed via the snippet below.

# Install development dependencies
install.packages(c(
  "devtools",
  "testthat",
  "shinytest2",
  "httr",
  "withr",
  "callr",
  "usethis",
  "mvtnorm",
  "readxl",
  "styler",
  "knitr",
  "rmarkdown",
  "DiagrammeR",
  "sessioninfo"
))

Testing

The included tests can be run with the following snippet.

devtools::test()

It is recommended to also run a more detailed check via the following snippet.

devtools::check()

Formatting

After making changes to the code, it is advised to automatically format all code with the {styler} package. This can be done with the following snippet.

styler::style_pkg()

Documentation

The documentation website is powered by {pkgdown}. It can be rebuilt with the following snippet.

pkgdown::build_site()

To set up everything for hosting the documentation on github pages use usethis::use_pkgdown_github_pages().

During development, roxygen2::roxygenise() is useful to update .Rd-files.

Acknowledgments

This project is funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – Project numbers 290773872 and 460037581.

Copy Link

Version

Install

install.packages('occupationMeasurement')

Monthly Downloads

242

Version

0.3.2

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Jan Simson

Last Published

September 27th, 2023

Functions in occupationMeasurement (0.3.2)

page_choose_one_option

Show a page with multiple radio button options where once can be picked.
questionnaire_demo

A demo questionnaire with additional explanations
page_feedback

Page to receive feedback on how well the chosen suggestion fits
page_select_suggestion

Display the generated suggestions for the user to pick one.
page_second_freetext

An optional, second free text question if the first didn't yield suggestions.
pretrained_models

Pretrained ML models to be used with the package.
questionnaire_web_survey

A web survey which participants can navigate themselves.
train_similarity_based_reasoning

Train Similarity Based Probability Model with anonymized training data
page_followup

Show potential followup questions to the user.
load_kldb_raw

Clean & Load KldB 2010 dataset.
page_freetext

Show a page with a text field where free text can be entered.
get_job_suggestions

Make coding suggestions based on a user's open-ended text input.
questionnaire_interviewer_administered

A questionnaire for interviewer-administered surveys
preprocess_string

Preprocess a string, removing special characters and handling abbreviations.
page_welcome

Welcome Page (optional)
page_first_freetext

The first freetext question to show.
api

Start the occupation coding API.
validate_questionnaire

Validate (and sanitize the questionnaire)
load_auxco

Load AuxCO from a directory of CSV files
set_page_data

Set some values in the page/questionnaire data in the current session.
leaving_page_backwards

Called internally by the shiny server when navigating to the previous page.
execute_run_before

Called internally by the shiny server.
execute_render

Called internally by the shiny server.
page_final

A final page, showing instructions to close the window.
page_results

Page showing the user's results
get_data

Load a standard dataset, while supporting overriding by the user.
page_none_selected_freetext

An additional freetext page to show when no suggestion has been selected.
set_item_data

Set / save data for an item.
execute_run_after

Called internally by the shiny server when navigating to the next page.
convert_suggestions

Convert suggestion from one suggestion format into the other
create_app_settings

Create app_settings.
app

Get an instance of the interactive shiny occupation coding app.
algo_similarity_based_reasoning

Make suggestions using similarity based reasoning.
auxco

German Auxiliary Classification of Occupations (AuxCO) v1.2.3
get_responses

Convenience function to aggregate all saved results_overview files.
get_page_data

Get questionnaire / page data.
button_next

Go to the next page
check_condition

Called internally by the shiny server.
get_item_data

Retrieve data for an item.
get_suggestion_info

Get additional information for a suggestion id.
get_final_codes

Get the final occupation codes
new_page

Create a new questionnaire page.
isco_08_en

Categories of the The International Standard Classification of Occupations - ISCO-08
get_followup_questions

Get potential follow-up questions for a suggestion.