diff --git a/modules/cheatsheets/Day-1.md b/modules/cheatsheets/Day-1.md index 81b7fe48..16dd8351 100644 --- a/modules/cheatsheets/Day-1.md +++ b/modules/cheatsheets/Day-1.md @@ -1,35 +1,42 @@ --- -classoption: -- landscape +classoption: landscape +output: + pdf_document: default + html_document: + df_print: paged --- # Day 1 Cheatsheet -## Intro +## Basic R ### Major concepts -- **Package** - a package in R is a bundle or “package” of code (and or possibly data) -that can be loaded together for easy repeated use or for sharing with others. -- **Function** - a function is a particular piece of code that allows you to do -something in R. You can write your own, use functions that come directly from -installing R, or use functions from additional packages. +- **Package** - a package in R is a bundle or “package” of code (and or possibly data) that can be loaded together for easy repeated use or for sharing with others. Like an "expansion pack". +- **Function** - a function is a particular piece of code that allows you to dosomething in R. You can write your own, use functions that come directly from installing R, or use functions from additional packages. - **Argument** - an option that you specify to a function. -- **Object** - an object is something that can be worked with in R - can be lots of -different things! -- **Variable** something measured or counted that is a characteristic about a -sample. -- **Sample** individuals that you have data about - e.g. people, houses, viruses etc.\ -- **Data frames** A collection of variables and samples in a row/column format. Sample = Row, Variable = Column -- [**Tidyverse**](https://tidyverse.tidyverse.org/articles/paper.html) - This is a newer set of packages designed for data science that can make your -code more intuitive as compared to the original older Base R. - +- **Object** - an object is something that can be worked with in R - can be lots of different things! +- [**Tidyverse**](https://tidyverse.tidyverse.org/articles/paper.html) - This is a newer set of packages designed for data science that can make your code more intuitive as compared to the original older Base R. +- The R console is a full calculator: + - `+`, `-`, `/`, `*` are add, subtract, divide and multiply + - `^` or `**` is power + - parentheses – ( and ) – work with order of operations + - %% finds the remainder +- `#` is the comment symbol; nothing to its right is evaluated. ### Functions |Library/Package|Piece of code|Example of usage|What it does| |---------------|-------------|----------------|-------------| -|Base `R`|[`install.packages()`](https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/install.packages)| `install.packages("remotes")`| Installs packages| -|Base `R`| [`library()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/library)|`library(remotes)`| Loads and attaches additional packages to the R environment.| +| Base `R`| [`<-`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/assignOps.html)| `x <- 1`| Assigns a name `x` to something in the R environment.| +| Base `R`| [`c()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/c)| `x <- c(1, 3)`| Combines values into a vector. | +| Base `R`| [`str()`](https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/str)|`str(x)`| Gets a summary of the object `x` structure.| +| Base `R`| [`class()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/class)|`class(x)`| Returns the type of the values in object `x`.| +| Base `R`| [`length()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/length)|`length(x)`| Returns how long the object `x` is. | +| Base `R`| [`seq()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/seq)|`seq(from = 0, to = 100, by = 5)`| Generate regular sequences. | +| Base `R`| [`rep()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/rep)|`rep(1, times = 10)`| Replicates the values in x. Can take `times` or `length.out` argument.| +| Base `R`| [`sample()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/sample)|`sample(1:12)`| Takes a sample of the specified size from the elements of x using either with or without replacement. `replace = TRUE` samples with replacement. | +| Base `R`| [`install.packages()`](https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/install.packages)| `install.packages("tidyverse")`| Installs packages| +| Base `R`| [`library()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/library)|`library(tidyverse)`| Loads and attaches additional packages to the R environment. Done every time you start R.|
@@ -56,26 +63,4 @@ output.
-## Reproducibility - -### Major concepts - -- **Reproducibility** - A different analyst re-performs the analysis with the same code and the same data and obtains the same -result. -- **Repeatable** - keeping everything the same but repeating the analysis - do we get the same results -- **Reproducible** - using the same data and analysis but in the hands of another researcher - do we get the same results? -- **Replicable** - with new data do we obtain the same inferences? - -### Functions -|Library/Package|Piece of code|Example of usage|What it does| -|---------------|-------------|----------------|-------------| -| Base `R`| [`sessionInfo()`](https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/sessionInfo) |`sessionInfo()`| Returns the R version information, the OS, and the attached packages in the current R session.| - -### More resources -- [The RMarkdown book](https://bookdown.org/yihui/rmarkdown/) -- [Jenny Bryan's organizational strategies](https://www.stat.ubc.ca/~jenny/STAT545A/block19_codeFormattingOrganization.html). -- [Write efficient R code for science](https://www.earthdatascience.org/courses/earth-analytics/automate-science-workflows/write-efficient-code-for-science-r/). -- [Reproducibility in Cancer Informatics course](https://jhudatascience.org/Reproducibility_in_Cancer_Informatics/introduction.html) - - \* This format was adapted from the [cheatsheet format from AlexsLemonade](https://github.com/AlexsLemonade/training-modules/tree/master/module-cheatsheets). diff --git a/modules/cheatsheets/Day-1.pdf b/modules/cheatsheets/Day-1.pdf index 646ffb6d..d40c0f04 100644 Binary files a/modules/cheatsheets/Day-1.pdf and b/modules/cheatsheets/Day-1.pdf differ diff --git a/modules/cheatsheets/Day-2.md b/modules/cheatsheets/Day-2.md index 6732b201..1e131a7a 100644 --- a/modules/cheatsheets/Day-2.md +++ b/modules/cheatsheets/Day-2.md @@ -1,33 +1,30 @@ --- -classoption: -- landscape +classoption: landscape +output: pdf_document --- # Day 2 Cheatsheet -## Basic R +## Reproducibility ### Major concepts -- **Package** - a package in R is a bundle or “package” of code (and or possibly data) -that can be loaded together for easy repeated use or for sharing with others. -- The R console is a full calculator: - - `+`, `-`, `/`, `*` are add, subtract, divide and multiply - - `^` or `**` is power - - parentheses – ( and ) – work with order of operations - - %% finds the remainder -- `#` is the comment symbol; nothing to its right is evaluated. - +- **Reproducibility** - A different analyst re-performs the analysis with the same code and the same data and obtains the same +result. +- **Repeatable** - keeping everything the same but repeating the analysis - do we get the same results +- **Reproducible** - using the same data and analysis but in the hands of another researcher - do we get the same results? +- **Replicable** - with new data do we obtain the same inferences? ### Functions |Library/Package|Piece of code|Example of usage|What it does| |---------------|-------------|----------------|-------------| -| Base `R`| [`<-`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/assignOps.html)| `x <- 1`| Assigns a name to something in the R environment.| -| Base `R`| [`c()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/c)| `x <- c(1, 3)`| Combines values into a vector or list. | -| Base `R`| [`str(x)`](https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/str)|`str(x)`| Gets a summary of the object `x` structure.| -| Base `R`| [`class(x)`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/class)|`class(x)`| Returns the type of the values in object `x`.| -| Base `R`| [`print(x)`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/print)|`print(x)`| Prints out contents of `x`.| -| Base `R`| [`length(x)`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/length)|`length(x)`| Returns how long the object `x` is. | +| Base `R`| [`sessionInfo()`](https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/sessionInfo) |`sessionInfo()`| Returns the R version information, the OS, and the attached packages in the current R session.| + +### More resources +- [The RMarkdown book](https://bookdown.org/yihui/rmarkdown/) +- [Jenny Bryan's organizational strategies](https://www.stat.ubc.ca/~jenny/STAT545A/block19_codeFormattingOrganization.html). +- [Write efficient R code for science](https://www.earthdatascience.org/courses/earth-analytics/automate-science-workflows/write-efficient-code-for-science-r/). +- [Reproducibility in Cancer Informatics course](https://jhudatascience.org/Reproducibility_in_Cancer_Informatics/introduction.html)
diff --git a/modules/cheatsheets/Day-2.pdf b/modules/cheatsheets/Day-2.pdf index 5fe895fd..74440881 100644 Binary files a/modules/cheatsheets/Day-2.pdf and b/modules/cheatsheets/Day-2.pdf differ