```{=html}
```r library(learnr) library(submitr) library(googlesheets4) library(gradethis) library(CKteachR) knitr::opts_chunk$set(echo = FALSE) learnr::tutorial_options( exercise.timelimit = 60, exercise.checker = gradethis::grade_learnr)
submitr::login_controls()
options(tutorial.storage = "none") out <- setup_progress_monitoring( rstudioapi::getActiveProject(), "PHDL1_week1", "15oXGGq0fgFL7kN3ZCcouhJhnIY_wJCDj3tPu6nyug-g", "1niWt2nCC3cgKtMEpowFVTTlVHBCbVpJl1WK-uR4r6BU", # week 1 spreadsheet "UoL.MPH.datalab@gmail.com" ) submitr::shiny_logic(input, output, session, out$vfun, out$storage_actions)
Learning R is like learning a foreign language. It may seem hard at first, but in time allows you to immerse into a new exciting culture.
If you feel that things don't make sense, don't worry. Everyone who uses R (or any other programming language) has been there, and we still do sometimes. Just ask your R-buddy or ask me!
During the PH data lab session, feel free to interrupt me at any time.
Some of the examples and exercises in this tutorial are inspired by a tutorial by Graeme L. Hickey
Derives from a proprietary software package called 'S-Plus'
"R is a free software programming language and software environment for statistical computing and graphics" Wikipedia (2014)
The "lingua franca of data analysts" The New York Times (2009)
Used worldwide by epidemiologists, bioinformaticians, data scientists, high-level statisticians, app developers, . . .
Keep whole analysis together (data processing, analysis, publication figures, reports)
Reproducible research
State of the art statistical methods are wrapped up in 'R packages'
It is free and open-source
It is used by many companies & institutions including the UK Government
The primary objective is for you to be able to apply statistical functions available in R to your own data.
To achieve this you should be able to:
Understand the core concepts of R and its syntax
Be able to read and write data files
Be able to interrogate a dataset
Be able to use functions and options
By now you you should all have received installation instructions. You can also download them from the links below.
R looks like this. You type commands, you press enter, and R executes the commands.
{width=70%}
RStudio is an integrated development environment (IDE) for R. That means that RStudio makes the experience working with R more comfortable and speeds-up the development time of R projects. So, one could use R without RStudio (or any other IDE) and achieve the same results. Still, most likely, the work would be more time-consuming and less enjoyable.
We will deep into Rstudio in the coming weeks.
question("Why use R? (Select ALL that apply)", answer("Allows reproducible research", correct = TRUE), answer("Free & open-source", correct = TRUE), answer("State of the art statistical methods", correct = TRUE), answer("To complicate our lifes", message = "It may feel that is too complicated in the beginning, but eventually the experience becomes smoother."), incorrect = "Incorrect. We use R because it offers state of the art statistical methods, it is free, and allows reproducible research.", allow_retry = TRUE, random_answer_order = TRUE )
All R functions have documentation that is in most cases excellent
From within R you can access the documentation of a function by typing ?function
where function is the function name
From within RStudio access the documentation of a function by using the help pane
All the above are useful for functions that are in R packages that you have installed already. To access the documentation from any function available to R, even from packaged you have not installed, you can use Rdocumentation.org
R has an unfortunate name that confuses many search engines
Of course you can keep using your favourite search engine and evenually may learn and prioritise sites about the R language
Another option is Rseek.org that is a topic-specific search engine about R topics and issues
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.