knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of nemsr is to enable researchers to quickly calculate NEMS-S scores for individual grocery stores using a Qualtrics-based NEMS-S survey developed at BYU.
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("byu-transpolab/nemsr")
The NEMS-S data should come from a Qualtrics survey collected by a trained
surveyor. Download the data from Qualtrics in the .sav
format (for SPSS).
Then you can read the data into R with the read_nemss
function.
library(nemsr) ## basic example code file <- system.file("extdata", "example_nems.sav", package = "nemsr") (nemss <- read_nemss(file))
Once the data are in your R session, there are two basic things you might like to do with them: a NEMS-S score and a market basket score.
The calculate_nems_score()
function computes the NEMS scores related
to the cost and availability of healthier options at each grocery store.
Additionally, a few variables relevant to the size and type of the store are
returned in a tibble.
calculate_nems_score(nemss)
There is also a detail
argument to this function that returns data columns
showing the detail of the price and availability calculations.
calculate_nems_score(nemss, detail = TRUE)
The calculate_market_basket()
function computes the cost of a common market
basket at that store using the pricing data available weighted according to the
Thrifty Food Plan, 2021
(basket_score <- calculate_market_basket(nemss))
For details on this function, its methods, and return information, see ?calculate_market_basket()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.