0% found this document useful (0 votes)
7 views8 pages

R Code for Blood Lactate Analysis

This document provides a detailed tutorial on using R software to calculate blood lactate endurance markers, including installation instructions and code examples. It covers how to set up the environment, load necessary libraries and datasets, and perform analyses for individual athletes and teams. The results can be exported to text files for further use.

Uploaded by

Tibor Pogonyi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views8 pages

R Code for Blood Lactate Analysis

This document provides a detailed tutorial on using R software to calculate blood lactate endurance markers, including installation instructions and code examples. It covers how to set up the environment, load necessary libraries and datasets, and perform analyses for individual athletes and teams. The results can be exported to text files for further use.

Uploaded by

Tibor Pogonyi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

R Code for Calculating Blood

Lactate Endurance markers


Dr. John Newell, August 2006.

A paper detailing the algorithms used to calculate the markers has been submitted to the
Journal of Sports Science under the title “Software for Calculating Blood Lactate
Endurance Markers” (J. Newell, D. Higgins, N. Madden, J. Cruikshank, J. Einbeck). It is
expected that use of this software will be acknowledged by a suitable reference.

The Lactate-R software has been written in R, a powerful free computer language for
statistical computing. R is open-source software which can be downloaded at
[Link] . Follow the Cran link under Download and select a mirror
site nearest you. The R code described in this tutorial is written for the Windows
platform. Click on the Windows (95 and later) option in the ‘Download and Install R’
box, click on Base and then on [Link]. You will be prompted to Open or
Save the software

Save the software to a folder of your choice and once the download is completed, double
click on the saved file to install the software. Once completed an R icon will appear on

the desktop as . R is now installed and ready for use.

Before activating R, create a new folder called Lactatemarkers on the C drive.

Unzip the [Link] file into the Lactatemarkers folder you have just
created.

1
Activate R in Windows by double clicking on the R icon on the desktop. The following
screen should now appear. Note that R is command line driven software.

The version of R is given including some useful information for new users, including
instructions on how to quit R form the command line. When R starts it automatically
searches for any saved work in the current directory. On leaving R it will offer to save
the current session allowing you to continue your work from session to session. This is
particularly useful in the context described here as once the lactate software has been
loaded, the workspace can be saved thus avoiding the necessity to reload the software
each time it is needed.

Tutorials on the many features of in R are available on the R homepage. In this article
emphasis is on using the R platform to calculate lactate endurance markers.

The first step is to install the pspline library, needed for calculating the D2lmax marker in
particular, as follows:

¾ select the drop down menu File and choose Change Directory
¾ select Browse and navigate to the Lactatemarkers folder on the C drive.
¾ press OK
¾ select the drop down menu Packages and choose Install package(s) from local
zip files
¾ select [Link]
¾ press Open.

2
Once this is finished and the > prompt returns in the R Console screen, type

library(pspline)

and press Return. The > prompt returns indicating that the command has been processed
and the pspline library is installed.

The next step is to read in the lactate markers code. In the R console copy and paste the
following line of code:

source('C:\\Lactatemarkers\\[Link]')

and press Return. This command reads in the functions contained in the file
[Link] necessary to calculate the markers.

Following this load in the two sample datasets by pasting the following two lines into R

[Link]<-[Link]('C:\\Lactatemarkers\\[Link]', header=TRUE)
[Link]<-[Link]('C:\\Lactatemarkers\\[Link]', header=TRUE)
[Link]<-[Link]('C:\\Lactatemarkers\\[Link]', header=TRUE)

and press Return. You have now loaded three sample data sets, which have been given
the names [Link], [Link] and [Link] respectively into the
workspace. The subcommand ‘header=TRUE’ specifies that the dataset contains
variable names. The data represent lactate and corresponding workload measurements
collected from a long distance runner. In the R console type

[Link]

and press Return, to view the data from the sample runner.

> [Link]
Workload JP
1 50 2.8
2 75 2.4
3 100 2.4
4 125 2.9
5 150 3.1
6 175 4.0
7 200 5.8
8 225 9.3
9 250 12.2
10 275 NA
11 300 NA
12 325 NA

3
The data were originally typed in Excel and saved as a text file. Note that the first
column contains the Workloads while the second contains the ‘Blood Lactate readings
corresponding to each workload. The first column is given the label Workload and the
athlete in question is given the label JB. A missing value is represented by an NA. Any
future datasets that you wish to analyse needs to follow the same convention. The order
the columns appear is critical in that the first column is always reserved for the Workload
readings!

You are now ready to use the lactate markers code.

Single Analysis Example.

To calculate Lactate Markers for the sample athlete type

[Link]([Link])

and press Return. The following output should now appear

Workrate
LT 182.17
[Link] 145.47
4mmol 170.46
Rise1mmol 166.51
Dmax 165.05
D2LMax 183.33
D2LMax Discrete 175.00

with the accompanying graph (overleaf).

4
The graph can be copied into the clipboard and pasted into a word processor if necessary.
To export the results as a dataset the results must first be saved as an object within R and
then the object written to a file. This can be carried out using the following commands:

results1<-[Link]([Link])
[Link](results1, “[Link]”)

The results will be written to a file called [Link] which will be located in the
C:\Lactatemarkers folder.

5
Team Analysis

In the R console type

[Link]

and press Return, to view the data from the sample squad.

> [Link]
Workload DA JP LL DB CS MM JT AB RG WH DR
1 50 2.7 2.8 2.3 2.1 2.5 2.3 2.2 2.2 2.3 2.8 3.0
2 75 2.9 2.4 2.0 1.9 2.4 2.4 2.0 1.6 2.5 3.0 3.2
3 100 2.6 2.4 1.8 1.8 2.7 1.7 1.4 1.8 2.9 3.0 3.0
4 125 2.7 2.9 1.8 1.6 3.6 1.8 1.6 1.5 2.6 3.2 2.0
5 150 2.8 3.1 2.1 2.0 4.8 2.1 2.0 1.4 3.3 3.8 1.7
6 175 3.8 4.0 2.3 2.8 5.8 1.6 2.2 1.6 7.1 3.7 2.1
7 200 5.4 5.8 3.5 4.3 10.4 1.9 3.2 1.6 9.3 4.1 2.3
8 225 9.1 9.3 5.6 5.7 12.4 1.8 4.0 2.4 11.4 5.5 5.1
9 250 13.2 12.2 7.9 9.6 14.4 3.4 5.0 4.2 21.4 6.2 5.6
10 275 NA NA 10.4 11.6 NA 4.4 8.8 7.6 22.8 7.8 8.8
11 300 NA NA 12.6 13.6 NA 6.5 10.9 NA NA 9.4 12.0
12 325 NA NA NA NA NA 8.6 13.0 NA NA NA NA

Once again the data were originally typed in Excel and saved as a text file. The first
column contains the Workloads while the remaining contains the blood lactate readings
for each workload for each squad member. A missing value is represented by an NA.

To calculate Lactate Markers for a Squad type

[Link] ([Link])

and press Return. The following output will now appear.

> [Link] ([Link])


DA JP LL DB CS MM JT AB RG
LT 172.26 182.17 185.60 182.24 124.77 230.43 214.96 267.70 160.81
[Link] 162.39 145.47 146.94 141.17 98.49 217.02 160.77 206.44 137.00
4mmol 178.69 170.46 201.23 191.17 135.11 267.28 219.56 244.41 146.76
Rise1mmol 173.26 166.51 187.51 174.52 126.32 253.32 202.63 233.89 135.22
Dmax 174.16 165.05 179.28 170.60 133.68 219.78 197.63 196.55 165.12
D2LMax 202.75 183.33 187.89 220.42 168.72 290.04 246.55 146.85 218.02
D2LMax Discrete 175.00 175.00 150.00 200.00 150.00 200.00 225.00 225.00 200.00

WH DR
LT 198.62 230.63
[Link] 188.67 174.16
4mmol 182.15 223.77
Rise1mmol 171.66 223.77
Dmax 199.02 200.02
D2LMax 266.72 266.22
D2LMax Discrete 175.00 225.00

6
To export the results as a dataset the results must first be saved as an object within R as in
the previous example as outlined below:

resultssquad<- [Link] ([Link])


[Link](resultssquad, “[Link]”)

The results will be written to a file called [Link] which will be located in the
C:\Lactatemarkers folder.

Timeline Analysis

The same function as used in the squad analysis can be used to calculate the markers for
an athlete over time. For example, in the R console type

[Link]

and press Return, to view the data from the sample squad.

Workload Subject1Lactate1 Subject1Lactate2 Subject1Lactate3


1 12.5 0.70 0.80 0.60
2 13.0 0.70 0.80 0.35
3 13.5 0.70 0.90 0.60
4 14.0 0.70 0.80 0.50
5 14.5 1.15 0.95 0.60
6 15.0 1.30 1.00 0.80
7 15.5 1.75 1.60 0.95
8 16.0 2.50 2.00 1.15
9 16.5 3.25 2.45 1.80
10 17.0 4.40 3.40 2.40
11 17.5 5.65 5.00 3.40
12 18.0 NA NA 4.85

Once again the data were originally typed in Excel and saved as a text file. The first
column contains Workload while the remaining columns contain the blood lactate
readings for the same athlete at different times e.g. beginning, middle and end of the
season and missing values are represented by an NA.

To calculate the Lactate Markers for this individual over time type

[Link]([Link])

and press Return.

7
The following output will now appear

[Link] ([Link])

Subject1Lactate1 Subject1Lactate2 Subject1Lactate3


LT 15.62 16.26 16.23
[Link] 13.87 14.73 14.73
4mmol 16.84 17.18 17.72
Rise1mmol 15.40 15.93 16.38
Dmax 15.32 15.61 15.89
D2LMax 16.77 17.00 17.48
D2LMax Discrete 13.50 16.50 12.50

As before the results can be exported as a dataset in a similar manner as follows:

resultstime<- [Link] ([Link])


[Link](resultstime, “[Link]”)

The results will be written to a file called [Link] which will be located in the
C:\Lactatemarkers folder.

You might also like