Skip to content

Commit

Permalink
update cheatsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
avahoffman committed Oct 1, 2024
1 parent 6125e35 commit 733fa75
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules/cheatsheets/Day-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@ result.
- **Getting help** - For any function, you can write `?FUNCTION_NAME`, or `help("FUNCTION_NAME")` to
look at the help file for that function.
- [**R Projects**](https://support.rstudio.com/hc/en-us/articles/200526207-Using-RStudio-Projects) set the working directory where the .Rproj file is.
- [**R Markdown**](https://bookdown.org/yihui/rmarkdown-cookbook/working-directory.html) files look for file paths relative to where the `.Rmd` file is located
- **Reading in data (manual)** - *Download the data*, *Put data in the project folder*. Go to File, Import Dataset, From Text (`readr`), browse for the file, and finally click "Update" and "Import".

### Functions
|Library/Package|Piece of code|Example of usage|What it does|
|---------------|-------------|----------------|-------------|
| `readr`| [`read_csv()`](https://www.rdocumentation.org/packages/readr/versions/1.3.0/topics/read_delim)| `df <- read_csv("<url>")`| Reads in a TSV file from a specified file path. This function can be tailored to read in other common types of files. i.e. read_csv(), read_rds(), etc.|
|`readxl`| [`read_excel()`](https://www.rdocumentation.org/packages/readxl/versions/1.3.1/topics/read_excel)| `read_excel("dataset.xlsx")`| Read in an excel file.|
| `tidyverse` (`readr`)| [`read_csv()`](https://www.rdocumentation.org/packages/readr/versions/2.1.5/topics/read_csv)| `df <- read_csv("<url>")`| Reads in a CSV file from a specified file path.|
| `tidyverse` (`readr`)| [`read_tsv()`](https://www.rdocumentation.org/packages/readr/versions/2.1.5/topics/read_tsv)| `df <- read_tsv("<url>")`| Reads in a TSV file from a specified file path.|
| `tidyverse` (`readr`)| [`read_delim()`](https://www.rdocumentation.org/packages/readr/versions/2.1.5/topics/read_delim)| `df <- read_delim("<url>", delim = ":")`| Reads in a delimited file from a specified file path.|
| Base `R`| [`head()` / `tail()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/head)| `head(df)` / `tail(df)` | Returns the first or last part of a dataset (or other object).|
| Base `R`| [`getwd()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/getwd)| `getwd()`| Finds the current working directory.|
| Base `R`| [`setwd()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/getwd)| `setwd("Desktop")`| Changes the current working directory.|

| Base `R`| [`View()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/View)| `View(df)`| View a spreadsheet-style data viewer on a matrix-like R object.|
| Base `R`| [`str()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/str)| `str(df)`| Display the internal structure of an R object (dimensions, class, etc).|

\* This format was adapted from the [cheatsheet format from AlexsLemonade](https://github.com/AlexsLemonade/training-modules/tree/master/module-cheatsheets).

0 comments on commit 733fa75

Please sign in to comment.