- Ctrl+Shift+F10 or Session/Restart R as doesn't automatically reset so all packages will be loaded
- Save workspace to .RData on exit = Ask
- Tick Restore .RData into workspace at startup
- Appearance RStudio theme = Modern
- Ambience = Clouds
- Editor font size = 10
- Box plot in a Board Report: https://www.dpt.nhs.uk/resources/corporate-information/board-papers/2020-board-papers Sept board paper p.39.
Stackoverflow
- dplyr was plyr
- data.table
- look for newer posts, might have fewer votes. Deprecated verbs (pivot_longer/pivot_wider was gather/spread)
- nhsrcommunity.slack.com, R-Ladies, @miR_community
Editor
- Do not have to highlight whole chunks to run (unlike in SQL), anywhere in chunk for Ctrl + Enter
- Back tick ``, '', "" interchangeable and automatically does closing.
- Highlight word and select quotes, automatic for beginning and end.
Packages
- Packages for SPCs qicharts2 on CRAN, https://github.com/johnmackintosh/runcharter not on CRAN but clear instructions on how to install. Used in a Shiny app https://github.com/royal-free-london/RunCharter_Shiny
- Useful for finding files when network paths are set up like: \NHS- X-XX01\Users2\X\Name
- Avoid setwd()
- Tibbles are a re-imagining of data frames https://blog.rstudio.com/2016/03/24/tibble-1-0-0/. Show first 10 rows in console with information on the table whereas dataframes show entirety.
- + must come at the end of the line, not at the beginning of the next
- group_by() does not reduce a number of similar rows to 1 like SQL. Two ways to reproduce this:
group_by_all() %<% slice(1) - takes first, if you do slice(2) takes 2nd not 1 and 2
or unique()
Extension
- summarise(uniqueNumber = n_distinct(id))
- When joining on column names that don't match, the order of the given names is important. c("country" = "Place") will work but c("Place", "country") will not
- Also very useful as a proof of concept before building a Shiny app
- Using source("example.R") is useful within R Markdown reports to split out further data wrangling from the report
- Section scripts Ctrl+Shift+R. See listed either at the bottom of the console, bottom left just above the tabs for Console/Terminal/Jobs or button next to Source top right of console.
- R Markdown chunks are Ctrl+Alt+i (works in cloud)
- Ctrl+Shift+1 makes the Console the prominant screen
- Further shortcuts and set own Tools/Keyboard Shortcuts Help or Modify Keyboard Shortcuts...
- Everyone is ok for emails to be shared for certificates.