From f0f315e0e2be9d279634c073f4b446e7e82cab81 Mon Sep 17 00:00:00 2001 From: ytakemon Date: Wed, 6 Nov 2024 08:35:48 -0800 Subject: [PATCH 1/5] adding callout for Code writing style --- episodes/01-r-basics.Rmd | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/episodes/01-r-basics.Rmd b/episodes/01-r-basics.Rmd index d3d4ed99..eb74c541 100644 --- a/episodes/01-r-basics.Rmd +++ b/episodes/01-r-basics.Rmd @@ -143,6 +143,25 @@ In the 'Environment' window you will also get a table: The 'Environment' window allows you to keep track of the objects you have created in R. + +::::::::::::::::::::::::::::::::::::::::: callout + +## Tip: Use of white space for readability + +The white space surrounding the assignment operator `<-` in the example +above (`first_value <- 1`) is unnecessary. However, it does make your code +easier to read. There are several style guides you can follow, and choosing +one is up to you, but consistency is key! + +A style guide we recommend is the Tidyverse [style guide](https://style.tidyverse.org/). As they say: + +"Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread." + +:::::::::::::::::::::::::::::::::::::::::::::::::: + + + + ::::::::::::::::::::::::::::::::::::::: challenge ## Exercise: Create some objects in R From 4476590b61311d0ade24be581921fe9b038f29ab Mon Sep 17 00:00:00 2001 From: ytakemon Date: Tue, 12 Nov 2024 09:10:26 -0800 Subject: [PATCH 2/5] addresses #300 --- episodes/01-r-basics.Rmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/episodes/01-r-basics.Rmd b/episodes/01-r-basics.Rmd index eacf331b..62c18d62 100644 --- a/episodes/01-r-basics.Rmd +++ b/episodes/01-r-basics.Rmd @@ -148,12 +148,13 @@ created in R. ## Tip: Use of white space for readability -The white space surrounding the assignment operator `<-` in the example +The white spaces surrounding the assignment operator `<-` in the example above (`first_value <- 1`) is unnecessary. However, it does make your code easier to read. There are several style guides you can follow, and choosing one is up to you, but consistency is key! -A style guide we recommend is the Tidyverse [style guide](https://style.tidyverse.org/). As they say: +A style guide we recommend is the Tidyverse [style guide](https://style.tidyverse.org/). +As they say: "Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread." From 995409003932524fc6742d1b3ef0c24fcef0c115 Mon Sep 17 00:00:00 2001 From: ytakemon Date: Tue, 12 Nov 2024 09:16:30 -0800 Subject: [PATCH 3/5] Decided to not going into depth on assignment operators but will address this issue via style guide arguemnt. Fixes #301 --- episodes/01-r-basics.Rmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/episodes/01-r-basics.Rmd b/episodes/01-r-basics.Rmd index 62c18d62..03183688 100644 --- a/episodes/01-r-basics.Rmd +++ b/episodes/01-r-basics.Rmd @@ -211,8 +211,9 @@ Here are some important details about naming objects in R. a colored highlight or RStudio gives you a suggested autocompletion you have chosen a name that has a reserved meaning. - **Use the recommended assignment operator**: In R, we use '\<- ' as the - preferred assignment operator. '=' works too, but is most commonly used in - passing arguments to functions (more on functions later). There is a shortcut + preferred assignment operator, which is recommended by the Tidyverse + [style guide](https://style.tidyverse.org/) discussed above. '=' works too, but is most + commonly used in passing arguments to functions (more on functions later). There is a shortcut for the R assignment operator: - Windows execution shortcut: Alt\+\- - Mac execution shortcut: Option\+\- From 590068aa038b98de550ec4b3e30c1d96679cf765 Mon Sep 17 00:00:00 2001 From: ytakemon Date: Tue, 12 Nov 2024 09:21:57 -0800 Subject: [PATCH 4/5] Modified an example to include a demo and blurb on character case sensitivity to fix #305 --- episodes/01-r-basics.Rmd | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/episodes/01-r-basics.Rmd b/episodes/01-r-basics.Rmd index 03183688..c232df7f 100644 --- a/episodes/01-r-basics.Rmd +++ b/episodes/01-r-basics.Rmd @@ -751,12 +751,15 @@ the vector you are searching: # current value of 'snp_genes': # chr [1:7] "OXTR" "ACTN3" "AR" "OPRM1" "CYP1A1" NA "APOA5" -# test to see if "ACTN3" or "APO5A" is in the snp_genes vector +# test to see if "ACTN3", "APO5A", or "actn3" is in the snp_genes vector # if you are looking for more than one value, you must pass this as a vector -c("ACTN3","APOA5") %in% snp_genes +c("ACTN3","APOA5", "actn3") %in% snp_genes ``` +Notice that the gene "actn3" is FALSE? This is because character vectors are case sensitive, so +keep this in mind when subsetting and selecting values from a character vector. + ::::::::::::::::::::::::::::::::::::::::: callout ## Tip: What's the difference between the `%in% and the `==` operators? From 25c7adb821b6647bc8ec4ae5fe46206afa6cf0e4 Mon Sep 17 00:00:00 2001 From: Naupaka Zimmerman Date: Mon, 9 Dec 2024 15:10:54 -0800 Subject: [PATCH 5/5] Fix grammar --- episodes/01-r-basics.Rmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/episodes/01-r-basics.Rmd b/episodes/01-r-basics.Rmd index c232df7f..3e4660a5 100644 --- a/episodes/01-r-basics.Rmd +++ b/episodes/01-r-basics.Rmd @@ -149,11 +149,12 @@ created in R. ## Tip: Use of white space for readability The white spaces surrounding the assignment operator `<-` in the example -above (`first_value <- 1`) is unnecessary. However, it does make your code +above (`first_value <- 1`) are unnecessary. However, including them does make your code easier to read. There are several style guides you can follow, and choosing one is up to you, but consistency is key! A style guide we recommend is the Tidyverse [style guide](https://style.tidyverse.org/). + As they say: "Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread."