knitr::opts_chunk$set( collapse = TRUE, comment = "#>")
The first step is we need to install the pscore
package.
The easiest way to do this is to install it from CRAN using the code below.
Note text after ## is a comment in R, so is there to help explain the code. The key lines of code to actually run are highlighted.
## install the pscore package install.packages("pscore")
Now we need to start or load the package.
This is a bit like installing an app on your phone.
You need to install it first, but when you want to use it, you need to
tap it to start it. In R
we "start" a particular app or package
by using the library()
function and the name of the package
as in the code below.
library(pscore)
Metabolic syndrome represents a cluster of risk factors for cardiovascular disease and diabetes that frequently co-occur. Metabolic syndrome comprises:
Metabolic syndrome is defined as the presence of at least 3/5 risk factors, according to guidelines from a joint scientific statement by the International Diabetes Federation Task Force on Epidemiology and Prevention; National Heart, Lung, and Blood Institute; American Heart Association; World Heart Federation; International Atherosclerosis Society; and International Association for the Study of Obesity:
Alberti, K. G. M. M., Eckel, R. H., Grundy, S. M., Zimmet, P. Z., Cleeman, J. I., Donato, K. A., . . . Smith, S. C. (2009). Harmonizing the Metabolic Syndrome: A Joint Interim Statement of the International Diabetes Federation Task Force on Epidemiology and Prevention; National Heart, Lung, and Blood Institute; American Heart Association; World Heart Federation; International Atherosclerosis Society; and International Association for the Study of Obesity. Circulation, 120(16), 1640-1645. doi: 10.1161/circulationaha.109.192644
Clinical thresholds exist for each of the markers. Different units are provided, where appropriate, and alternate markers that are not in the guidelines, but may be used if no other data are available, along with approximately equivalent thresholds.
| | Females | Males | |-----------------------|------------------------------------------|------------------------------------------| | Waist circumference | >= 80 cm (31 in) [~BMI >= 25] | >= 94 cm (37 in) [~BMI >= 25] | | Triglycerides | >= 1.7 mmol/L (150 mg/dL) | >= 1.7 mmol/L (150 mg/dL) | | HDL Cholesterol | < 1.3 mmol/L (50 mg/dL) | < 1.0 mmol/L (40 mg/dL) | | Hypertension | >= 130 mm Hg SBP and/or >= 85 mm Hg DBP | >= 130 mm Hg SBP and/or >= 85 mm Hg DBP | | Fasting blood glucose | >= 5.6 mmol/L (100 mg/dL [~HbA1c >= 5.7] | >= 5.6 mmol/L (100 mg/dL [~HbA1c >= 5.7] |
In addition to the dichotomous presence or absence of the metabolic syndrome condition, a metabolic syndrome "severity" or "symptom" score can be created, by combining scores on individual biomarkers into a composite. Advantages of such a composite is that it:
The metabolic syndrome severity score (or MetSSS) can be calculated using the
pscore
package in R
. This work is based on:
Wiley, J. F. & Carrington, M. J. (2016). A metabolic syndrome severity score: A tool to quantify cardio-metabolic risk factors. Preventive Medicine, 88, 189-195. https://doi.org/10.1016/j.ypmed.2016.04.006.
Note that when using this calculator, it is important to specify the following variables.
In specifying them, the spelling and capitalization of variable names must be exact as
must be the values for sex
.
sex
: Female
or Male
for each set of values, stored as character strings or text. Capitalization matters.sbp
: systolic blood pressure in mm Hgdbp
: diastolic blood pressure in mm Hgtrigs
: triglycerides in mmol/Lhdl
: high density lipoprotein cholesterol in mmol/Lglucose
: blood glucose in mmol/Lwaist
: waist circumference in centimetersBuild into the pscore
package is a sample data file formatted exactly
how the data needs to be formatted to score it. The data are stored
as a CSV file. You can find the location on your computer where
the sample dataset is stored using this code:
system.file("extdata", "sample_metsss.csv", package = "pscore")
We will read that sample CSV dataset into R
to show how
pscore
can be used to score it and calculate the MetSSS.
Here we read the data in using the read.csv()
function.
The data are stored in R
under the name d
.
Note that if you wanted to use this code on your own, real data instead of this example dataset, you only need to change the path to where your data are stored on your computer. For example changing to something like:
d <- read.csv("C:/path/to/your/data/your_data.csv")
## load data d <- read.csv( system.file("extdata", "sample_metsss.csv", package = "pscore"))
The table that follows shows what the example dataset looks like. It has five different values and just the variables required for calculating the metabolic syndrome severity score (MetSSS).
knitr::kable(d)
We can also check the str
ucture of the data to see
how R
sees the dataset, using the str()
function.
This can be useful because even if you think the data are
created and formatted correctly, if R
is not reading it in
correctly, you may have trouble calculating the MetSSS.
Here is the structure for the sample data.
Your real data should look similar.
str(d)
Once we have the dataset loaded and have confirmed that the variables are named
correctly and that the values are correct, scoring the MetSSS using the
weights derived in the Wiley and Carrington (2016) paper can be done
using the MetSSS()
function as below. We save the results as a new
object, dscored
.
## use the MetSSS calculator to score the data dscored <- MetSSS(d)
The object dscored
should look exactly like the dataset you used, with one
extra column or variable added, metsss
which is the calculated
metabolic syndrome severity score.
Here is a table showing what the scored dataset looks like for the sample data.
knitr::kable(dscored)
Finally, if you want to save your results or analyze the MetSSS
outside of R
, you can write the dataset with the scored MetSSS variable
back out as a CSV file using the code that follows.
## this will tell you where the file will be saved by R getwd() ## save the scored data back to a CSV file write.csv(dscored, file = "scored_metsss.csv", row.names = FALSE)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.