knitr::opts_chunk$set( collapse = TRUE, eval = FALSE, comment = "#>" ) options(rmarkdown.html_vignette.check_title = FALSE) frag_path <- here::here("man", "fragments", "bfi") paths <- list.files(frag_path, "Rmd", full.names = TRUE) names(paths) <- gsub("\\.Rmd", "", basename(paths)) paths <- as.list(paths)
library(questionnaires)
bfi
functions# Making some test data test_data <- tibble( id = rep(1:10, each = 60), name = rep(sprintf("bfi_%02d", 1:60), 10), value = lapply(1:10, function(x){ sample(1:5, size = 60, replace = TRUE) }) %>% unlist() ) %>% tidyr::pivot_wider() test_data
To compute all the possible domains and facets, as long as the data is set up correctly, you can run a single function
bfi_compute(test_data)
You also have some options in terms of prefixing the data, and if you want to keep all the original data in the output as well.
bfi_compute(test_data, keep_all = TRUE) bfi_compute(test_data, prefix = "bfi_")
There are two main ways you can compute domains alone.
These two ways are equivalent, and take prefix
and keep_all
arguments.
bfi_compute(test_data, type = "domains") bfi_compute_domains(test_data)
You can also choose to compute only certain domains, either by calling on their own special function or by specifying a domain in the main domain function.
## Computes all bfi_compute_domains(test_data, domains = c("extraversion", "agreeableness", "conscientiousness", "negative emotionality", "open-mindedness")) ## extraversion and agreeableness only bfi_compute_domains(test_data, domains = c("extraversion", "agreeableness")) ## only agreeableness, returned as a vector, not a data.frame bfi_domain_agreeable(test_data) ## So it can be used in a mutate, but, awkwardly mutate(test_data, agree = bfi_domain_agreeable(test_data)) %>% select(agree, everything())
There are two main ways you can compute facets alone.
These two ways are equivalent, and take prefix
and keep_all
arguments.
bfi_compute(test_data, type = "facets") bfi_compute_facets(test_data)
You can also choose to compute only certain domains, either by calling on their own special function or by specifying a domain in the main domain function.
## Computes all bfi_compute_facets(test_data, facets = c("sociability", "assertiveness", "energy", "compassion", "respectful", "trust", "organization", "productive", "responsibility", "anxiety", "depression", "emotional volatility", "intellectual curiosity", "aesthetic sensebility", "creative imagination")) ## extraversion and agreeableness only bfi_compute_facets(test_data, facets = c("anxiety", "depression")) ## only anxiety, returned as a vector, not a data.frame bfi_facet_anxiety(test_data) ## So it can be used in a mutate, but, awkwardly mutate(test_data, anx = bfi_domain_agreeable(test_data)) %>% select(anx, everything())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.