The first step is we need to install the
The easiest way to do this is to install it from CRAN using the code
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
“start” a particular app or package by using the
function and the name of the package as in the code below.
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.
|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
pscore package in
R. This work is
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
Malefor each set of values, stored as character strings or text. Capitalization matters.
sbp: systolic blood pressure in mm Hg
dbp: diastolic blood pressure in mm Hg
trigs: triglycerides in mmol/L
hdl: high density lipoprotein cholesterol in mmol/L
glucose: blood glucose in mmol/L
waist: waist circumference in centimeters
Build 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") #>  "C:/Users/jwile/AppData/Local/Temp/RtmpmEbJM4/Rinst9e9c8f6290f/pscore/extdata/sample_metsss.csv"
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
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 <- read.csv( d 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).
We can also check the
structure of the data to see how
R sees the dataset, using the
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) #> 'data.frame': 5 obs. of 7 variables: #> $ sbp : num 138 138 147 125 120 #> $ dbp : num 91.5 69 80.5 63 59 #> $ trigs : num 1.37 5.41 4.31 1.16 1.07 #> $ hdl : num 2 1.19 0.7 0.39 1.86 #> $ waist : num 101.5 106 99.5 101 82.9 #> $ glucose: num 5.16 6.46 8.19 6.28 5.99 #> $ sex : chr "Male" "Female" "Male" "Female" ...
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,
## use the MetSSS calculator to score the data <- MetSSS(d)dscored
dscored should look exactly like the dataset
you used, with one extra column or variable added,
which is the calculated metabolic syndrome severity score. Here is a
table showing what the scored dataset looks like for the sample
Finally, if you want to save your results or analyze the MetSSS
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)