Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martinctc/surveytoolbox
A R package containing useful support functions for survey analysis.
https://github.com/martinctc/surveytoolbox
r survey-analysis
Last synced: 3 months ago
JSON representation
A R package containing useful support functions for survey analysis.
- Host: GitHub
- URL: https://github.com/martinctc/surveytoolbox
- Owner: martinctc
- Created: 2018-12-29T00:18:47.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-03T16:14:44.000Z (about 1 year ago)
- Last Synced: 2023-11-03T17:29:22.854Z (about 1 year ago)
- Topics: r, survey-analysis
- Language: R
- Homepage: https://martinctc.github.io/surveytoolbox/
- Size: 409 KB
- Stars: 21
- Watchers: 6
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# surveytoolbox
[![R build status](https://github.com/martinctc/surveytoolbox/workflows/R-CMD-check/badge.svg)](https://github.com/martinctc/surveytoolbox/actions)
[![CodeFactor](https://www.codefactor.io/repository/github/martinctc/surveytoolbox/badge)](https://www.codefactor.io/repository/github/martinctc/surveytoolbox)R package containing tidy support functions for survey analysis.
Currently under development!
(First created 29 Dec 2018)------------------------------------------------------------------------
### About this package
It is from my own experience of analysing survey data in R that whilst more often than not you're able to do what you want to do, there is a sense that the 'essential functions' are scattered across different packages and Stack Overflow answers. This is understandable, as the workflow of every analyst is bound to be unique, and it isn't necessarily sensible to have 100-odd functions collected in a single package for each user - there is bound to be a need to draw functions from multiple packages.
This is a curated collection of functions that I've either written or come across over the past years. In my analysis workflow, I often use these functions in conjunction with `tidyverse`, `srvyr` (allows you to work with weighted data), and `janitor`. There are also some miscellaneous functions which work with common survey analysis techniques such as factor analysis (using the `factanal()` function from `stats)
**The aim of this package is to attempt to organise things a bit and add value by curation.**
Additional reading on functions from this package:
- [Working with SPSS labels in R](https://martinctc.github.io/blog/working-with-spss-labels-in-r/)
- Applying the timestamp function `timed_fn()`: [RStudio Projects and Working Directories: A Beginner's Guide](https://martinctc.github.io/blog/rstudio-projects-and-working-directories-a-beginner%27s-guide/)---
### Summary of Functions
There are broadly several groups of functions that you can find in this package:
- Creating dummy variables, and variations of these which take inputs from multiple categorical variables (`superspread()`)
- Copying data to and from Excel for ad-hoc analysis (`copy_df()`)
- Functions for changing the scale of Likert-scale type questions, including Max-Min Scaling (`likert_reverse()`)
- Cleaning variable names
- Converting .sav (SPSS) files to smaller, faster-to-load RDS files (e.g. `sav_to_rds()`)
- Converting one or more categorical variable(s) into other variable types, such as dummy variables (binary), count variables (numeric), or "fill" variables (fills values from a required column if condition is TRUE)
- Functions for recoding variable and value labels (e.g. `recode_vallab()`, `set_varl()`, `set_vall()`)There is also a convenience function (`apply_row()`) for performing rowwise operations, which is particularly useful when creating new variables based on a selection of columns on the datas.
---
### Installation
surveytoolbox is not released on CRAN (yet).
You can install the latest development version from GitHub with:```R
install.packages("devtools")
devtools::install_github("martinctc/surveytoolbox")
```
---### Examples
Here is an example of how to use the `apply_row()` function to create new variables:
```R
library(tidyverse)
library(surveytoolbox)# Create a new column called `Sepal_Sum`
# Sum all values with columns containing "Sepal"
iris %>%
mutate(Sepal_Sum = apply_row(., select_helpers = contains("Sepal"), sum, na.rm = TRUE))
```
---### News and Updates
This package is currently still under development, so it does come with a health advice: if you do wish to use them - have a check and run through the examples before assimilating them into your analysis.
Note: Previously named 'surveytools', but now renamed to 'surveytoolbox' avoid confusion with another similar package of the same name (8th March 2019).
12th Jan 2020 - Functions relating to modelling have now been moved to a new package [modeltoolbox](https://www.github.com/martinctc/modeltoolbox).
---
### Contact mePlease feel free to submit suggestions and report bugs:
Also check out my [website](https://martinctc.github.io) for my other work and packages.