Skip to content

Commit

Permalink
lab 6 update
Browse files Browse the repository at this point in the history
  • Loading branch information
jmledford3115 committed Jan 29, 2024
1 parent 0adea8c commit 5dbd7ed
Show file tree
Hide file tree
Showing 4 changed files with 3,525 additions and 5 deletions.
10 changes: 8 additions & 2 deletions lab6/lab6_1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ library("janitor")
```

## Load the data
For this lab, we will use the following dataset:
For this lab, we will use the following two datasets:

1. S. K. Morgan Ernest. 2003. Life history characteristics of placental non-volant mammals. Ecology 84:3402. [link](http://esapubs.org/archive/ecol/E084/093/)
1. 1. Gaeta J., G. Sass, S. Carpenter. 2012. Biocomplexity at North Temperate Lakes LTER: Coordinated Field Studies: Large Mouth Bass Growth 2006. Environmental Data Initiative. [link](https://portal.edirepository.org/nis/mapbrowse?scope=knb-lter-ntl&identifier=267)

2. S. K. Morgan Ernest. 2003. Life history characteristics of placental non-volant mammals. Ecology 84:3402. [link](http://esapubs.org/archive/ecol/E084/093/)

## Pipes `%>%`
Recall that we use pipes to connect the output of code to a subsequent function. This makes our code cleaner and more efficient. One way we can use pipes is to attach the `clean_names()` function from janitor to the `read_csv()` output.
```{r}
fish <- readr::read_csv("data/Gaeta_etal_CLC_data.csv")
```

```{r}
mammals <- read_csv("data/mammal_lifehistories_v2.csv") %>% clean_names()
```
Expand Down
6 changes: 3 additions & 3 deletions lab6/lab6_2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ These are data taken from comic books and assembled by fans. The include a good

Check out the way I am loading these data. If I know there are NAs, I can take care of them at the beginning. But, we should do this very cautiously. At times it is better to keep the original columns and data intact.
```{r}
superhero_info <- read_csv("data/heroes_information.csv", na = c("", "-99", "-"))
superhero_powers <- read_csv("data/super_hero_powers.csv", na = c("", "-99", "-"))
#superhero_info <- read_csv("data/heroes_information.csv", na = c("", "-99", "-"))
#superhero_powers <- read_csv("data/super_hero_powers.csv", na = c("", "-99", "-"))
```

## Data tidy
Expand All @@ -37,7 +37,7 @@ superhero_powers <- read_csv("data/super_hero_powers.csv", na = c("", "-99", "-"
## `tabyl`
The `janitor` package has many awesome functions that we will explore. Here is its version of `table` which not only produces counts but also percentages. Very handy! Let's use it to explore the proportion of good guys and bad guys in the `superhero_info` data.
```{r}
tabyl(superhero_info, alignment)
#tabyl(superhero_info, alignment)
```

1. Who are the publishers of the superheros? Show the proportion of superheros from each publisher. Which publisher has the highest number of superheros?
Expand Down
1,797 changes: 1,797 additions & 0 deletions lab6_1.html

Large diffs are not rendered by default.

1,717 changes: 1,717 additions & 0 deletions lab6_2.html

Large diffs are not rendered by default.

0 comments on commit 5dbd7ed

Please sign in to comment.