diff --git a/modules/Data_Input/Data_Input.Rmd b/modules/Data_Input/Data_Input.Rmd index 32492a51..7694be3b 100644 --- a/modules/Data_Input/Data_Input.Rmd +++ b/modules/Data_Input/Data_Input.Rmd @@ -162,6 +162,17 @@ knitr::include_graphics("images/Data_Input_import_dataset.gif") - `>` browse for the file - `>` click "Update" and "Import" +## GUT CHECK! + +How can we get data into R? + +A. From a URL + +B. From a file we downloaded + +C. Both of these! + + ## Lab - Part 1 🏠 [Class Website](https://daseh.org/) @@ -334,14 +345,16 @@ Other file types Don't forget to use `<-` to assign your data to an object! -[Posit's Data Import Cheatsheet](https://rstudio.github.io/cheatsheets/data-import.pdf) - ## Lab - Part 2 🏠 [Class Website](https://daseh.org/) 💻 [Data Input Lab](https://daseh.org/modules/Data_Input/lab/Data_Input_Lab.Rmd) +❓ [Posit's Data Import Cheatsheet](https://rstudio.github.io/cheatsheets/data-import.pdf) + +❓ [Day 2 Cheatsheet](https://daseh.org/modules/cheatsheets/Day-2.pdf) + ```{r, fig.alt="The End", out.width = "50%", echo = FALSE, fig.align='center'} knitr::include_graphics(here::here("images/the-end-g23b994289_1280.jpg")) ``` diff --git a/modules/cheatsheets/Day-2.md b/modules/cheatsheets/Day-2.md index 1e131a7a..d501b404 100644 --- a/modules/cheatsheets/Day-2.md +++ b/modules/cheatsheets/Day-2.md @@ -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("")`| 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("")`| 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("")`| 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("", 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). diff --git a/modules/cheatsheets/Day-2.pdf b/modules/cheatsheets/Day-2.pdf index bc4a4dd0..98129f43 100644 Binary files a/modules/cheatsheets/Day-2.pdf and b/modules/cheatsheets/Day-2.pdf differ diff --git a/resources.Rmd b/resources.Rmd index 09a654b5..1942e375 100644 --- a/resources.Rmd +++ b/resources.Rmd @@ -28,8 +28,8 @@ Here are additional resources to help you on your R journey - either before, dur
**Class Cheatsheets**
-- [Day 1 - RStudio & Reproducibility Cheatsheet](https://daseh.org/modules/cheatsheets/Day-1.pdf) -- [Day 2 - Basic R & Data Input/Output Cheatsheet](https://daseh.org/modules/cheatsheets/Day-2.pdf) +- [Day 1 - Basic R & RStudio Cheatsheet](https://daseh.org/modules/cheatsheets/Day-1.pdf) +- [Day 2 - Reproducibility & Data Input/Output Cheatsheet](https://daseh.org/modules/cheatsheets/Day-2.pdf) - [Day 3 - Data Subsetting Cheatsheet](https://daseh.org/modules/cheatsheets/Day-3.pdf) - [Day 4 - Data Summarization & Data Classes Cheatsheet](https://daseh.org/modules/cheatsheets/Day-4.pdf) - [Day 5 - Data Cleaning Cheatsheet](https://daseh.org/modules/cheatsheets/Day-5.pdf)