Skip to content

Commit

Permalink
markdown source builds
Browse files Browse the repository at this point in the history
Auto-generated via `{sandpaper}`
Source  : 5c3da53
Branch  : main
Author  : Naupaka Zimmerman <[email protected]>
Time    : 2024-11-08 18:30:19 +0000
Message : Merge pull request #906 from kaijagahm/fix-likes-string

Change "likes_string" to "likes_catnip"
  • Loading branch information
actions-user committed Nov 8, 2024
1 parent 0637a16 commit 7cfe376
Show file tree
Hide file tree
Showing 5 changed files with 1,134 additions and 17 deletions.
30 changes: 15 additions & 15 deletions 04-data-structures-part1.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ making a toy dataset in your `data/` directory, called `feline-data.csv`:
``` r
cats <- data.frame(coat = c("calico", "black", "tabby"),
weight = c(2.1, 5.0, 3.2),
likes_string = c(1, 0, 1))
likes_catnip = c(1, 0, 1))
```

We can now save `cats` as a CSV file. It is good practice to call the argument
Expand All @@ -49,7 +49,7 @@ The contents of the new file, `feline-data.csv`:


``` r
coat,weight,likes_string
coat,weight,likes_catnip
calico,2.1,1
black,5.0,0
tabby,3.2,1
Expand All @@ -74,7 +74,7 @@ cats
```

``` output
coat weight likes_string
coat weight likes_catnip
1 calico 2.1 1
2 black 5.0 0
3 tabby 3.2 1
Expand Down Expand Up @@ -247,7 +247,7 @@ file.show("data/feline-data_v2.csv")


``` r
coat,weight,likes_string
coat,weight,likes_catnip
calico,2.1,1
black,5.0,0
tabby,3.2,1
Expand Down Expand Up @@ -314,7 +314,7 @@ while we investigate this behavior further:
feline-data.csv:

```
coat,weight,likes_string
coat,weight,likes_catnip
calico,2.1,1
black,5.0,0
tabby,3.2,1
Expand Down Expand Up @@ -516,24 +516,24 @@ may well be to blame; make sure everything is the same type in your vectors and
your columns of data.frames, or you will get nasty surprises!

But coercion can also be very useful! For example, in our `cats` data
`likes_string` is numeric, but we know that the 1s and 0s actually represent
`likes_catnip` is numeric, but we know that the 1s and 0s actually represent
`TRUE` and `FALSE` (a common way of representing them). We should use the
`logical` datatype here, which has two states: `TRUE` or `FALSE`, which is
exactly what our data represents. We can 'coerce' this column to be `logical` by
using the `as.logical` function:


``` r
cats$likes_string
cats$likes_catnip
```

``` output
[1] 1 0 1
```

``` r
cats$likes_string <- as.logical(cats$likes_string)
cats$likes_string
cats$likes_catnip <- as.logical(cats$likes_catnip)
cats$likes_catnip
```

``` output
Expand Down Expand Up @@ -1107,7 +1107,7 @@ cats
```

``` output
coat weight likes_string
coat weight likes_catnip
1 calico 2.1 TRUE
2 black 5.0 FALSE
3 tabby 3.2 TRUE
Expand Down Expand Up @@ -1203,7 +1203,7 @@ cats[1,]
```

``` output
coat weight likes_string
coat weight likes_catnip
1 calico 2.1 TRUE
```

Expand All @@ -1223,7 +1223,7 @@ str(cats[1,])
'data.frame': 1 obs. of 3 variables:
$ coat : chr "calico"
$ weight : num 2.1
$ likes_string: logi TRUE
$ likes_catnip: logi TRUE
```

::::::::::::::::::::::::::::::::::::::: challenge
Expand Down Expand Up @@ -1336,7 +1336,7 @@ cats[1, ]
```

``` output
coat weight likes_string
coat weight likes_catnip
1 calico 2.1 TRUE
```

Expand All @@ -1362,7 +1362,7 @@ names(cats)
```

``` output
[1] "coat" "weight" "likes_string"
[1] "coat" "weight" "likes_catnip"
```

If you want to rename the second column of `cats`, you can assign a new name to the second element of `names(cats)`.
Expand All @@ -1374,7 +1374,7 @@ cats
```

``` output
coat weight_kg likes_string
coat weight_kg likes_catnip
1 calico 2.1 TRUE
2 black 5.0 FALSE
3 tabby 3.2 TRUE
Expand Down
95 changes: 95 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#------------------------------------------------------------
# Values for this lesson.
#------------------------------------------------------------

# Which carpentry is this (swc, dc, lc, or cp)?
# swc: Software Carpentry
# dc: Data Carpentry
# lc: Library Carpentry
# cp: Carpentries (to use for instructor training for instance)
# incubator: The Carpentries Incubator
carpentry: 'swc'

# Overall title for pages.
title: 'R for Reproducible Scientific Analysis'

# Date the lesson was created (YYYY-MM-DD, this is empty by default)
created: '2015-04-18'

# Comma-separated list of keywords for the lesson
keywords: 'software, data, lesson, The Carpentries'

# Life cycle stage of the lesson
# possible values: pre-alpha, alpha, beta, stable
life_cycle: 'stable'

# License of the lesson materials (recommended CC-BY 4.0)
license: 'CC-BY 4.0'

# Link to the source repository for this lesson
source: 'https://github.com/swcarpentry/r-novice-gapminder'

# Default branch of your lesson
branch: 'main'

# Who to contact if there are any issues
contact: '[email protected]'

# Navigation ------------------------------------------------
#
# Use the following menu items to specify the order of
# individual pages in each dropdown section. Leave blank to
# include all pages in the folder.
#
# Example -------------
#
# episodes:
# - introduction.md
# - first-steps.md
#
# learners:
# - setup.md
#
# instructors:
# - instructor-notes.md
#
# profiles:
# - one-learner.md
# - another-learner.md

# Order of episodes in your lesson
episodes:
- 01-rstudio-intro.Rmd
- 02-project-intro.Rmd
- 03-seeking-help.Rmd
- 04-data-structures-part1.Rmd
- 05-data-structures-part2.Rmd
- 06-data-subsetting.Rmd
- 07-control-flow.Rmd
- 08-plot-ggplot2.Rmd
- 09-vectorization.Rmd
- 10-functions.Rmd
- 11-writing-data.Rmd
- 12-dplyr.Rmd
- 13-tidyr.Rmd
- 14-knitr-markdown.Rmd
- 15-wrap-up.Rmd

# Information for Learners
learners:

# Information for Instructors
instructors:

# Learner Profiles
profiles:

# Customisation ---------------------------------------------
#
# This space below is where custom yaml items (e.g. pinning
# sandpaper and varnish versions) should live


url: 'https://swcarpentry.github.io/r-novice-gapminder'
analytics: carpentries
lang: en
2 changes: 1 addition & 1 deletion data/feline-data.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"coat","weight","likes_string"
"coat","weight","likes_catnip"
"calico",2.1,1
"black",5,0
"tabby",3.2,1
2 changes: 1 addition & 1 deletion md5sum.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"episodes/01-rstudio-intro.Rmd" "04f6b758558750cef962768d78dd63b0" "site/built/01-rstudio-intro.md" "2024-11-05"
"episodes/02-project-intro.Rmd" "cd60cc3116d4f6be92f03f5cc51bcc3b" "site/built/02-project-intro.md" "2024-11-05"
"episodes/03-seeking-help.Rmd" "d24c310b8f36930e70379458f3c93461" "site/built/03-seeking-help.md" "2024-11-05"
"episodes/04-data-structures-part1.Rmd" "5ec938f71a9cec633cef9329d214c3a0" "site/built/04-data-structures-part1.md" "2024-11-05"
"episodes/04-data-structures-part1.Rmd" "afc6c3ced3677ab088457152f8d84b54" "site/built/04-data-structures-part1.md" "2024-11-08"
"episodes/05-data-structures-part2.Rmd" "95c5dd30b8288090ce89ecbf2d3072bd" "site/built/05-data-structures-part2.md" "2024-11-05"
"episodes/06-data-subsetting.Rmd" "5d4ce8731ab37ddea81874d63ae1ce86" "site/built/06-data-subsetting.md" "2024-11-05"
"episodes/07-control-flow.Rmd" "6a8691c8668737e4202f49b52aeb8ac6" "site/built/07-control-flow.md" "2024-11-05"
Expand Down
Loading

0 comments on commit 7cfe376

Please sign in to comment.