Package 'gbhs'

Title: Lifebrain Global Brain Health Survey Data
Description: Between June 2019 and August 2020, Lifebrain conducted the Global Brain Health Survey to collect data on people’s perceptions of brain health and willingness to take care of their brain by adopting new lifestyles. The survey was conducted online and translated into 14 languages to reach as many people as possible. In total, it collected 27,590 responses from people in 81 countries. This package contains code and data from this survey.
Authors: Athanasia Mo Mowinckel [aut, cre]
Maintainer: Athanasia Mo Mowinckel <[email protected]>
License: CC BY 4.0 + file LICENSE
Version: 0.0.1.9000
Built: 2024-11-20 03:51:13 UTC
Source: https://github.com/lifebrain/gbhs

Help Index


Lifebrain Global Brain Health Survey

Description

Between June 2019 and August 2020, Lifebrain conducted the Global Brain Health Survey to collect data on people’s perceptions of brain health and willingness to take care of their brain by adopting new lifestyles. The survey was conducted online and translated into 14 languages to reach as many people as possible. In total, it collected 27,590 responses from people in 81 countries.

Usage

data(gbhs)

Format

An object of class tbl_df (inherits from tbl, data.frame) with 27590 rows and 107 columns.

Value

A data.frame with all responses

References

Budin-Ljøsne I, Friedman BB, Suri S, Solé-Padullés C, Düzel S, Drevon CA, Baaré WFC, Mowinckel AM, Zsoldos E, Madsen KS, Carver RB, Ghisletta P, Arnesen MR, Bartrés Faz D, Brandmaier AM, Fjell AM, Kvalbein A, Henson RN, Kievit RA, Nawijn L, Pochet R, Schnitzler A, Walhovd KB and Zasiekina L (2020) The Global Brain Health Survey: Development of a Multi-Language Survey of Public Views on Brain Health. Front. Public Health 8:387. doi: 10.3389/fpubh.2020.00387 (DOI)

Examples

data(gbhs)

Make GBHS question into long format data

Description

Several questions in the GBHS can be made into long format data, as they either contain data from multiple choice questions (each answer separated with a ';') or come from a group of questions exploring the same theme with the same response scale. This function collects these questions and responses into dedicated columns where the "key" column in the question asked and responses are stored in "value" ( response category), "continuous" (ordinal scale), and "bin" (binary scale). All other data remain in the data frame, but the number of rows is increased, and the "submission_id" column denotes the individual respondent.

Usage

gbhs_long_q(data, question)

Arguments

data

data.frame to work on. Needs to be a gbhs derivative

question

integer indicating which question to make the data longer from. Values accepted are 1,2,3,4

Value

data frame with long data

Examples

data(gbhs)
gbhs_long_q(gbhs, 2)
gbhs_long_q(gbhs, 4)

Get path of child document

Description

Get path of child document

Usage

gbhs_path_child(path = NULL, ...)

Arguments

path

filename of child document to get path of. If NULL, lists possibilities

...

other arguments to list.files

Value

string of file path

Source

This function is adapted from readxl::readxl_example().

Examples

gbhs_path_child()
gbhs_path_child("bin_desc.Rmd")
gbhs_path_child("ord_mod.Rmd")

Get file path to raw data

Description

The raw data from the survey is stored in individual files for each survey language. These are not cleaned or harmonised, as there are small inconsistencies in coding between the languages.

Usage

gbhs_path_data(path = NULL, type = "clean", destination = NULL, ...)

Arguments

path

Name of file in quotes with extension. If NULL, the example files will be listed.

type

type of data to look up. Either "clean" (default) or "raw"

destination

optional string indicating where to copy the file to

...

other arguments to list.files

Value

string of file path

Source

This function is adapted from readxl::readxl_example().

Examples

gbhs_path_data()
gbhs_path_data("114338_en.tsv")
head(read.delim(gbhs_path_data("114338_en.tsv")))
head(read.delim(gbhs_path_data("114338_en.tsv", "raw")))

Get path to meta-data and codebooks

Description

Get path to meta-data and codebooks

Usage

gbhs_path_meta(path = NULL, type = "codebook", ...)

Arguments

path

filename of utility file to get path of. If NULL, lists possibilities

type

either "codebook" or "meta-data"

...

other arguments to list.files

Value

string of file path

Source

This function is adapted from readxl::readxl_example().

Examples

gbhs_path_meta()
gbhs_path_meta("131674_ch.json")
gbhs_path_meta(type = "meta-data")
gbhs_path_meta("131674_ch.json", type = "meta-data")

Get file path to template files

Description

There are two basic type of template files, one descriptive and one with models. These are based on the exploration and testing of the data towards our publicised manuscripts and reports. To run the "model" documents, the corresponding "descriptive" document for that paper must have been previously run.

Usage

gbhs_path_rmd(type = "descriptives", paper = 1, destination = NULL)

Arguments

type

either "descriptive" (default) or "model"

paper

an integer of either 1,2 or 3.

destination

optional string indicating where to copy the file to

Value

string of file path

Source

This function is adapted from readxl::readxl_example().

Examples

gbhs_path_rmd()
gbhs_path_rmd("descriptive", 2)
gbhs_path_rmd("model", 3)

Get path of utility functions

Description

Get path of utility functions

Usage

gbhs_path_utilities(path = NULL, ...)

Arguments

path

filename of utility file to get path of. If NULL, lists possibilities

...

other arguments to list.files

Value

string of file path

Source

This function is adapted from readxl::readxl_example().

Examples

gbhs_path_utilities()
gbhs_path_utilities("data-utils.R")
gbhs_path_utilities("model-utils.R")

Render GBHS reports

Description

Descriptives and models for the GBHS data can be explored by generating the pre-created report templates.

Usage

gbhs_render_report(
  data = gbhs,
  type = "desc",
  paper = 1,
  output_dir = ".",
  ...
)

Arguments

data

data to be used. Can be a subselection of the gbhs data, or the entire gbhs data (default)

type

either "descriptive" (default) or "model"

paper

an integer of either 1,2 or 3.

output_dir

Directory to output the document to.

...

other arguments to render

Value

creats a report using the data and GBHS template

Examples

## Not run: 
gbhs_render_report(type = "desc", paper = 1)
gbhs_render_report(type = "desc", paper = 2)
gbhs_render_report(type = "mod", paper = 1)

## End(Not run)

Barchart for GBHS data

Description

Barchart for GBHS data

Usage

ggbar(data, grouping = NULL)

Arguments

data

GBHS data to plot

grouping

Grouping variable

Value

ggplot object

Examples

ggbar(gbhs_long_q(gbhs, 2))

Plot a model output from GBHS

Description

Utility function to plot model output from the GBHS survey

Usage

ggmodel(data, y, reverse = FALSE)

Arguments

data

data as prepared from prep_model_output

y

What goes on the y-axis

reverse

Should the scale be reversed

Value

ggplot object


Create a stacked bar chart

Description

Create a stacked bar chart

Usage

ggstacked(
  data,
  y = key,
  npos = 1.1,
  min_pc = 0.05,
  pattern = NULL,
  n_breaks = 2,
  text_size = 3
)

Arguments

data

data to plot

y

value for the y-axis

npos

position of sidebar text

min_pc

minimum percent to display text of

pattern

regex pattern to use with grepl for turning text white/black

n_breaks

number of break points

text_size

text size

Value

ggplot object


Wrap a ggstacked plot

Description

Wrap a ggstacked plot

Usage

ggstacked_wrap(data, y, ...)

Arguments

data

data to wrap

y

y-axis variable

...

other arguments to ggstacked

Value

ggplot object


Transform logit to probability

Description

Transform logit to probability

Usage

logit2prob(logit)

Arguments

logit

a vector of logit scale

Value

a vector of probabilities

Examples

logit2prob(c(0.5, 1, 1.5))

Remove columns with only NA

Description

In part of the cleaning process, we needed to easily remove columns that only contained NA values.

Usage

na_col_rm(data)

Arguments

data

data.frame with data

Value

data.frame without columns that only have NA values

Examples

na_col_rm(mtcars)

Calculate percent

Description

Calculate percent

Usage

pc(x)

Arguments

x

vector to calculate the percent from

Value

a vector of percents given the vectors whole.

Examples

pc(1:10)

Pretty percent displaying

Description

Pretty percent displaying

Usage

percent(x, accuracy = 1, ...)

Arguments

x

vector of numbers

accuracy

accuracy of the percent

...

other arguments to percent

Value

character vector with percentage sign at the end

Examples

percent(10)

Prepare model output for plots

Description

Models run come in an output that require a little work to get plotted. This function helps clean up and get the data prepared for plotting in particular.

Usage

prep_model_output(data, model, y, reverse = FALSE)

Arguments

data

Data used in the model

model

model output

y

what goes on the y-axis

reverse

whether the categorical scale should be reversed

Value

fortified data for plotting


Survey tibble

Description

There were in all 16 surveys launched for the global brain health survey. These were in different languages to try to capture as many respondents as possible, especially in Europe.

Usage

surveys()

Value

a tibble with 16 rows and 3 columns

Examples

surveys()

Format thousands

Description

Format thousands

Usage

thousand(x)

Arguments

x

numeric vector

Value

character vector where one thousands has a space to the next number

Examples

thousand(c(1000, 150000, 16000))