Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions episodes/00-before-we-start.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ The Default Layout is:
enters into the computer's working memory. The History tab displays all commands
that have been executed in the console.

- **Navigation Pane**
- **Files, Plots, Packages, and Help pane**
This pane has multiple functions:

- **Files:** Navigate to files saved on your computer and in your working directory
Expand Down Expand Up @@ -402,10 +402,9 @@ bioinformatics).

### **Installing packages using the Packages tab**

Installing CRAN packages can be done from the <kbd>Packages</kbd> tab in the Navigation
Pane. Click `Install` and type in the name of the package you're looking for.
Installing CRAN packages can be done from the <kbd>Packages</kbd> tab in the Files, Plots, Packages, and Help pane. Click `Install` and type in the name of the package you're looking for.

```{r install-packages, echo=FALSE, fig.cap="Click on the Packages tab in the Navigation Pane to download packages from CRAN.", fig.alt="install packages pane showing an entry for installing the 'tidyverse' package"}
```{r install-packages, echo=FALSE, fig.cap="Click on the Packages tab in the Files, Plots, Packages, and Help pane to download packages from CRAN.", fig.alt="install packages pane showing an entry for installing the 'tidyverse' package"}
knitr::include_graphics("fig/R_00_Rstudio_03.png")
```

Expand Down
2 changes: 1 addition & 1 deletion episodes/01-intro-to-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
- **Do not use names of functions that already exist in R:** There are some
names that cannot be used because they are the names of fundamental functions in
R (e.g., `if`, `else`, `for`, see
[here](https://stat.ethz.ch/R-manual/R-devel/library/base/html/Reserved.html)

Check warning on line 104 in episodes/01-intro-to-r.Rmd

View workflow job for this annotation

GitHub Actions / Build markdown source files if valid

[uninformative link text]: [here](https://stat.ethz.ch/R-manual/R-devel/library/base/html/Reserved.html)
for a complete list. In general, even if it's allowed, it's best to not use
other function names (e.g., `c`, `T`, `mean`, `data`, `df`, `weights`). If in
doubt, check the help to see if the name is already in use.
Expand Down Expand Up @@ -308,7 +308,7 @@
`sum(sqrt(9), 4)` to take the sum of the square root of 9 and add it to 4.

Typing a question mark before a function will pull the help page up in the
Navigation Pane in the lower right. Type `?sum` to view the help page for the
Files, Plots, Packages, and Help pane in the lower right. Type `?sum` to view the help page for the
`sum` function. You can also call `help(sum)`. This will provide the description
of the function, how it is to be used, and the arguments.

Expand Down
32 changes: 3 additions & 29 deletions episodes/02-starting-with-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,6 @@ to this episode and follow the instructions on creating an R project folder.
Once you have created the project, open the project in RStudio.


## Getting data into R

We will be using a demo dataset from the University of Houston--Clear Lake
Integrated Library System in 2018. It contains a relatively random sample of books
from the catalog.

In order to use your data in R, you must import it and turn it into an R *object*. There are many ways to get data into R.

- **Manually**: You can manually create it using the `data.frame()` function in Base R, or the `tibble()` function in the tidyverse.

- **Import it from a file** Below is a very incomplete list
- Text: TXT (`readLines()` function)
- Tabular data: CSV, TSV (`read.table()` function or `readr` package)
- Excel: XLSX (`xlsx` package)
- Google sheets: (`googlesheets` package)
- Statistics program: SPSS, SAS (`haven` package)
- Databases: MySQL (`RMySQL` package)

- **Gather it from the web**: You can connect to webpages, servers, or APIs
directly from within R, or you can create a data scraped from HTML webpages
using the `rvest` package. For example
- the Twitter API with
[`twitteR`](https://sites.google.com/site/miningtwitter/questions/talking-about/wordclouds/wordcloud1)
- Crossref data with
[`rcrossref`](https://cran.r-project.org/web/packages/rcrossref/rcrossref.pdf)
- World Bank's World Development Indicators with
[`WDI`](https://cran.r-project.org/web/packages/WDI/WDI.pdf).


### Set up your working directory

The working directory is an important concept to understand. It is the place
Expand Down Expand Up @@ -159,6 +130,9 @@ read.csv("./data") to represent that sub-directory.
::::::::::::::::::::::::::::::::::::::::::::::::::


## Getting data into R


## Downloading the data

Once you have set your working directory, we will create our folder
Expand Down
4 changes: 2 additions & 2 deletions episodes/04-data-viz-ggplot.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
The`lubridate` package is installed with the tidyverse, but is not one of the core tidyverse packages loaded with `library(tidyverse)`, so it needs to be explicitly called. `lubridate` makes working with dates and times easier in R.

We also load the `books_reformatted` data we saved in the previous
lesson. Here, we'll assign it to `books2`. You can create the reformatted data by running the codes from [here](https://librarycarpentry.github.io/lc-r/03-data-cleaning-and-transformation.html#exporting-data) or by loading the saved CSV file from previous episode.

Check warning on line 63 in episodes/04-data-viz-ggplot.Rmd

View workflow job for this annotation

GitHub Actions / Build markdown source files if valid

[uninformative link text]: [here](https://librarycarpentry.github.io/lc-r/03-data-cleaning-and-transformation.html#exporting-data)

```{r, purl=FALSE, eval=FALSE}
books2 <- read_csv("data_output/books_reformatted.csv") # load the data and assign it to books
Expand Down Expand Up @@ -109,7 +109,7 @@
- The `mapping` argument defines the variables mapped to various aesthetics of the plot, e.g. the x and y axis.
- The `geom_function` argument defines the type of plot, e.g. barplot, scatter plot, boxplot.

::::::::::::::::::::::::::::::::::::::::::::; callout

Check warning on line 112 in episodes/04-data-viz-ggplot.Rmd

View workflow job for this annotation

GitHub Actions / Build markdown source files if valid

[unknown div] ::::::::::::::::::::::::::::::::::::::::::::; callout

## `ggplot2` versus `ggplot`

Expand All @@ -119,8 +119,8 @@


When you run the `ggplot()` function, it plots directly to the Plots tab in the
Navigation Pane (lower right). Alternatively, you can assign a plot to an R
object, then call `print()`to view the plot in the Navigation Pane.
Files, Plots, Packages, and Help pane (lower right). Alternatively, you can assign a plot to an R
object, then call `print()`to view the plot in the Files, Plots, Packages, and Help pane.


## Creating your first plot
Expand Down
Loading