Introduction to R for Clinical Data
Presented by the Children’s Hospital of Philadelphia (CHOP) R User Group and Arcus Data Education
Part I: Introduction
R Programming language for data analysis
RStudio Integrated development environment (IDE)
R Markdown Computational document format
RStudio Server
Hosted on a server
(in the cloud)
RStudio Desktop
Installed on your computer
There are some small server issues that won’t affect our work today but will create a couple of scary looking messages in your first exercise.
Failed to create bus connection: No such file or directory
Warning message: In system(“timedatectl”, intern = TRUE) : running command ‘timedatectl’ had status 1
Click the link in the chat to access the RStudio training environment.
Log in using your username and password.
Click “yes” once you see the RStudio panes.
Duke
"1881_at"
"31321_at"
"31725_s_at"
"32307_r_at"
MD Anderson
"1882_g_at"
"31322_at"
"31726_at"
"32308_r_at"
Do you see the off-by-one indexing error?
Off-by-one indexing error
Sensitive / resistant label reversal
Confounding in experimental design
Inclusion of data from non-reported sources
Wrong figure shown
… and simple problems are common.”
… is not reproducible!
Your closest collaborator is you from 6 months ago…
Go to File > New File > R Markdown. Click OK.
This will give you a handy template which is used to show you a working example of a simple R Markdown document. You will be asked to provide a title and author, and you can choose any values you like, such as “Test” or “My First Markdown”.
Run each chunk by clicking the green “play” button (). Note what happens.
Knit the document with the “ball of yarn” button (). Type “test” and click Save to save the HTML file. Inspect the HTML document.
03:00
In the Files pane, click on the folder exercises
.
Open the R Markdown file titled 01 – Introduction.Rmd
. Instructions for this exercise are in the text of the R Markdown document.
Click () when you are done.
05:00
Programming Language
IDE (Editor)
Document Format
Packages extend the functionality of R. Install with install.packages()
and load with library()
Functions do stuff. They accept Arguments as input and return an Output. Capture an output in an Object using the assignment operator ( <-
).
Importing Data is the first step of data analysis. Use read_csv()
from the tidyverse
package to import data stored in a CSV file.
Obviously in a five hour workshop we can barely scratch the surface… here are some other ideas to get you thinking.
In English: https://r4ds.had.co.nz/
English unofficial solutions at https://jrnold.github.io/r4ds-exercise-solutions/index.html
In Spanish: https://es.r4ds.hadley.nz/
```{python}
import pandas
covid_testing.info()
```
Children’s Hospital of Philadelphia (CHOP) R User Group