TimesaveR
R package to quickly perform data analysis and reporting tasks that might otherwise be time intensive
Install / Use
/learn @LukasWallrich/TimesaveRREADME
timesaveR <img src='man/figures/logo.png' align="right" height="139" />
<!-- badges: start --> <!-- badges: end -->This package aims to speed up research projects in social psychology (and related fields). For that, it primarily includes some functions that help lay the groundwork and others that facilitate the reporting of results.
Among others, the package can help with the following:
- Creating scales, including reverse-coding and reporting their internal consistency,
- Creating correlation tables in APA style, including descriptive statistics and confidence intervals, and an option to use survey weights, multiple imputation or full-information maximum-likelihood estimation
- Creating regression tables comparing standardised and non-standardised regression coefficients, and comparing the F-change between two nested models
- Formatting numbers for statistical reporting, including rounding with trailing zeros, or displaying numbers as p-values or as confidence intervals
- Data entry and transfer, for quick interactive use. This includes splitting clipboard content into vectors, converting tibbles to tribble code, or obtaining nicely formatted code and results to paste into another application
Why use this package?
There are many packages that support data analysis and reporting. For
instance, the psych package offers functions to create scales, while
the modelsummary package offers options to create customisable tables
in a wide variety of output format. They power many of the functions
offered here ‘under the hood.’
apa and papaja are two packages that directly support the reporting
of results in APA style - they can complement this package well.
However, none of the existing offered quite what we needed. This package
- takes an end-to-end view of the data analysis process, streamlining time-consuming steps at various stages
- offers analysis templates that make it easy to get started, particularly for R novices,
- prioritises publication-readiness and good reporting practices over customisability in creating tables and charts
- integrates with the
tidyverseby supporting tidy evaluation and returning tibbles where possible
Installation
You can install timesaveR from GitHub with the command below. If you do
not have the remotes-package installed, run
install.packages("remotes") first.
remotes::install_github('lukaswallrich/timesaveR')
Get started
There are many functions in the package, and we will create vignettes detailing various use cases. However, the following can give you an initial flavor. The examples use data from the European Social Survey Wave 7 (2014). Here, I ignore survey weights. However, the package offers similar functions for analysing weighted survey data, which are explained in the survey data vignette.
Load the package
(I also load dplyr since that is the recommended usage - of course,
there are base R alternatives for all of the steps.)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(timesaveR)
#> Note re timesaveR: Many functions in this package are alpha-versions - please treat results with care and report bugs and desired features.
Create scales
Let’s create scales for health behaviours and depressive symptoms, each including some reverse coding.
scales <- list(
depression = c("fltdpr", "flteeff", "slprl", "wrhpp", "fltlnl",
"enjlf", "fltsd", "cldgng"),
healthy_eating = c("etfruit", "eatveg")
)
scales_reverse <- list(
depression = c("wrhpp", "enjlf"),
healthy_eating = c("etfruit", "eatveg")
)
scales <- make_scales(ess_health, items = scales, reversed = scales_reverse)
#> The following scales will be calculated with specified reverse coding: depression, healthy_eating
<img src="man/figures/README-create-scales-1.png" width="100%" /><img src="man/figures/README-create-scales-2.png" width="100%" />
#Check descriptives, including reliability
scales$descriptives
#> # A tibble: 2 × 10
#> Scale n_items reliability reliability_method mean SD reversed rev_min
#> <chr> <int> <dbl> <chr> <dbl> <dbl> <chr> <dbl>
#> 1 depression 8 0.802 cronbachs_alpha 1.67 0.484 wrhpp e… 1
#> 2 healthy_e… 2 0.658 spearman_brown 4.97 1.11 etfruit… 1
#> # ℹ 2 more variables: rev_max <dbl>, text <chr>
#Add scale scores to dataset
ess_health <- bind_cols(ess_health, scales$scores)
Report correlations and descriptive statistics
Next, we are often interested in descriptive statistics, variable distributions and correlations.
ess_health %>% select(agea, health, depression, healthy_eating) %>%
cor_matrix() %>% report_cor_table()
<div id="uuaxumjvmz" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#uuaxumjvmz table {
font-family: times, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
#uuaxumjvmz thead, #uuaxumjvmz tbody, #uuaxumjvmz tfoot, #uuaxumjvmz tr, #uuaxumjvmz td, #uuaxumjvmz th { border-style: none; }
#uuaxumjvmz p { margin: 0; padding: 0; }
#uuaxumjvmz .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 12px; font-weight: normal; font-style: none; background-color: #FFFFFF; width: auto; border-top-style: none; border-top-width: 2px; border-top-color: #FFFFFF; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
#uuaxumjvmz .gt_caption { padding-top: 4px; padding-bottom: 4px; }
#uuaxumjvmz .gt_title { color: #333333; font-size: 12px; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
#uuaxumjvmz .gt_subtitle { color: #333333; font-size: 12px; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
#uuaxumjvmz .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
#uuaxumjvmz .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #000000; }
#uuaxumjvmz .gt_col_headings { border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
#uuaxumjvmz .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
#uuaxumjvmz .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
#uuaxumjvmz .gt_column_spanner_outer:first-child { padding-left: 0; }
#uuaxumjvmz .gt_column_spanner_outer:last-child { padding-right: 0; }
#uuaxumjvmz .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
#uuaxumjvmz .gt_spanner_row { border-bottom-style: hidden; }
#uuaxumjvmz .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
#uuaxumjvmz .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: none;
Related Skills
feishu-drive
353.3k|
things-mac
353.3kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
353.3kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
postkit
PostgreSQL-native identity, configuration, metering, and job queues. SQL functions that work with any language or driver
