Skip to content

Commit

Permalink
Merge pull request #191 from fhdsl/input-final-updates
Browse files Browse the repository at this point in the history
Finalizing some changes for [Data input]
  • Loading branch information
avahoffman authored Oct 1, 2024
2 parents 0b55658 + ceafd21 commit b6f644b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
17 changes: 15 additions & 2 deletions modules/Data_Input/Data_Input.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down Expand Up @@ -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"))
```
Expand Down
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).
Binary file modified modules/cheatsheets/Day-2.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions resources.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Here are additional resources to help you on your R journey - either before, dur

<details><summary> <span style = "color: #5383bb;"> **Class Cheatsheets**</span></summary><br>

- [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)
Expand Down

0 comments on commit b6f644b

Please sign in to comment.