Skip to content

Commit 7be8cdb

Browse files
committed
differences for PR #304
1 parent 368fb94 commit 7be8cdb

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

01-r-basics.md

+29-5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@ In the 'Environment' window you will also get a table:
144144
The 'Environment' window allows you to keep track of the objects you have
145145
created in R.
146146

147+
148+
::::::::::::::::::::::::::::::::::::::::: callout
149+
150+
## Tip: Use of white space for readability
151+
152+
The white spaces surrounding the assignment operator `<-` in the example
153+
above (`first_value <- 1`) is unnecessary. However, it does make your code
154+
easier to read. There are several style guides you can follow, and choosing
155+
one is up to you, but consistency is key!
156+
157+
A style guide we recommend is the Tidyverse [style guide](https://style.tidyverse.org/).
158+
As they say:
159+
160+
"Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread."
161+
162+
::::::::::::::::::::::::::::::::::::::::::::::::::
163+
164+
165+
166+
147167
::::::::::::::::::::::::::::::::::::::: challenge
148168

149169
## Exercise: Create some objects in R
@@ -193,8 +213,9 @@ Here are some important details about naming objects in R.
193213
a colored highlight or RStudio gives you a suggested autocompletion you have
194214
chosen a name that has a reserved meaning.
195215
- **Use the recommended assignment operator**: In R, we use '\<- ' as the
196-
preferred assignment operator. '=' works too, but is most commonly used in
197-
passing arguments to functions (more on functions later). There is a shortcut
216+
preferred assignment operator, which is recommended by the Tidyverse
217+
[style guide](https://style.tidyverse.org/) discussed above. '=' works too, but is most
218+
commonly used in passing arguments to functions (more on functions later). There is a shortcut
198219
for the R assignment operator:
199220
- Windows execution shortcut: <KBD>Alt</KBD>\+<KBD>\-</KBD>
200221
- Mac execution shortcut: <KBD>Option</KBD>\+<KBD>\-</KBD>
@@ -900,16 +921,19 @@ the vector you are searching:
900921
# current value of 'snp_genes':
901922
# chr [1:7] "OXTR" "ACTN3" "AR" "OPRM1" "CYP1A1" NA "APOA5"
902923

903-
# test to see if "ACTN3" or "APO5A" is in the snp_genes vector
924+
# test to see if "ACTN3", "APO5A", or "actn3" is in the snp_genes vector
904925
# if you are looking for more than one value, you must pass this as a vector
905926

906-
c("ACTN3","APOA5") %in% snp_genes
927+
c("ACTN3","APOA5", "actn3") %in% snp_genes
907928
```
908929

909930
``` output
910-
[1] TRUE TRUE
931+
[1] TRUE TRUE FALSE
911932
```
912933

934+
Notice that the gene "actn3" is FALSE? This is because character vectors are case sensitive, so
935+
keep this in mind when subsetting and selecting values from a character vector.
936+
913937
::::::::::::::::::::::::::::::::::::::::: callout
914938

915939
## Tip: What's the difference between the `%in% and the `==` operators?

md5sum.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"config.yaml" "b91cd97fa3b408bd1ac0a00e67ab3219" "site/built/config.yaml" "2024-11-05"
55
"index.md" "7f9c30e6487338a0c3f8ecc4018873ab" "site/built/index.md" "2024-11-05"
66
"episodes/00-introduction.Rmd" "03f55a33cafd3e5f3b407315c509a389" "site/built/00-introduction.md" "2024-11-05"
7-
"episodes/01-r-basics.Rmd" "b45f835c7d4314da15066f1f2cb86b21" "site/built/01-r-basics.md" "2024-11-09"
7+
"episodes/01-r-basics.Rmd" "f936f90c2253243c164e28a97241b9c1" "site/built/01-r-basics.md" "2024-11-12"
88
"episodes/02-data-prelude.Rmd" "ab2b1fd3cdaae919f9e409f713a0a8ad" "site/built/02-data-prelude.md" "2024-11-05"
99
"episodes/03-basics-factors-dataframes.Rmd" "0bb7c8d7807eea75f14ce8ca3d22febf" "site/built/03-basics-factors-dataframes.md" "2024-11-05"
1010
"episodes/04-bioconductor-vcfr.Rmd" "10eb69b4697d7ecb9695d36c0d974208" "site/built/04-bioconductor-vcfr.md" "2024-11-05"

0 commit comments

Comments
 (0)