Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 105 incomplete scripts #107

Merged
merged 15 commits into from
Sep 26, 2024
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Each session contains the relevant datasets for the session, as well as the R fi
easily create dynamic documents, presentations and reports from R. It
combines markdown (simple formatting syntax) and embedded R code chunks that are run and can perform calculations. The R Markdown files are identified with a .Rmd suffix. See [How to use the session material](#how_to) for details on how to use R Markdown.

Within each session, the Rmd files which end with `_incomplete` are a version of the session material that is missing some code. Students should work through this version, and refer to the complete solution for answers. Session 2 contains two versions of the Rmd files. One version uses the old dplyr gather() and spread(), the other uses pivot_().
Within each session, the Rmd files which end with `_incomplete` are a version of the session material that is missing some code. Students should work through this version, and refer to the complete solution for answers. Code examples and exercises are provided in an R script file (ending with `_working_script.R`) in each session folder along with an R script containing solutions.

Session 2 contains two versions of the Rmd files. One version uses the old dplyr gather() and spread(), the other uses pivot_().

The housekeeping folder contains material that was used to develop the course and does not form part of the training.

Expand Down
17 changes: 8 additions & 9 deletions session1/intro_to_r_session1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ sepal_length_average <- iris %>%



In the above code, R is taking the 'iris' dataset, grouping it by Species and then (note that the data is "piped" like water into the group_by command using the pipe symbol '%>%' instead of specifying the 'iris' dataset as the first argument within the group_by command), and then outputting the mean length by species. The new mean number of Sepal.Length variable we've decided to call 'ave'. The results are saved into a new dataset called 'sepal_length_average'.
In the above code, R is taking the 'iris' dataset, grouping it by Species (note that the data is "piped" like water into the group_by command using the pipe symbol '%>%' instead of specifying the 'iris' dataset as the first argument within the group_by command), and then outputting the mean length by species. The new mean number of Sepal.Length variable we've decided to call 'ave'. The results are saved into a new dataset called 'sepal_length_average'.



Expand All @@ -730,8 +730,8 @@ The pipe operator simply passes through the object on the left hand side as the
```{r results="hide"}

sepal_length_average <-
summarise(group_by(iris,Species),
ave=mean(Sepal.Length))
summarise(group_by(iris, Species),
ave = mean(Sepal.Length))



Expand Down Expand Up @@ -988,7 +988,7 @@ staff_all <- full_join(staff_salaries,

```

For more information about the different sorts of joins and other data transformation functions see the 'Data Transformation Cheat Sheet' at: https://www.rstudio.com/resources/cheatsheets/
For more information about the different sorts of joins and other data transformation functions see the 'Data Transformation Cheat Sheet' at: https://rstudio.github.io/cheatsheets/html/data-transformation.html


### 4.2 Exporting data
Expand All @@ -1001,7 +1001,7 @@ A command to export data into csv format is write_csv from the readr package (th

```{r results="hide"}

write_csv(iris_petals, path = "iris_petals.csv")
write_csv(iris_petals, file = "iris_petals.csv")

```

Expand Down Expand Up @@ -1039,10 +1039,9 @@ There are lots of resources that can help you develop your R knowledge, but belo

+ DataCamp is a website which hosts multiple online courses that teach coding. Their 'Introduction to R' course is free to complete and provides a broader overview in the basic concepts for coding in R. A link to the course can be found here: https://www.datacamp.com/courses/free-introduction-to-r.

+ Another good resource is the 'R for Data Science' online book: [r4ds.had.co.nz/](r4ds.had.co.nz/), written by Hadley Wickham, who is a data scientist at RStudio, who developed the tidyverse package that we introduced earlier. It gives a really good overview of R and how his package works with it.
+ Another good resource is the 'R for Data Science' online book: [https://r4ds.hadley.nz/](https://r4ds.hadley.nz/), written by Hadley Wickham, who is a data scientist at RStudio, who developed the tidyverse package that we introduced earlier. It gives a really good overview of R and how his package works with it.

+ RStudio has also developed a list of 'cheatsheets' which give quick overviews of the functions contained in different packages, which can be quickly referred to: https://www.rstudio.com/resources/cheatsheets/ Some can be accessed directly through the top menu help > Cheatsheets e.g. 'Data Transformation with dplyr'.
+ RStudio has also developed a list of 'cheatsheets' which give quick overviews of the functions contained in different packages, which can be quickly referred to: https://posit.co/resources/cheatsheets/ Some can be accessed directly through the top menu help > Cheatsheets e.g. 'Data Transformation with dplyr'.



Further resources can be found on Saltire Analytical Professions pages (Analytical Professions > Analytical Tools > Analytical Software)
Further resources can be found on Stats group sharepoint site: https://scotsconnect.sharepoint.com/sites/StatisticsGroup-Org-SG/SitePages/R-Resources.aspx
27 changes: 12 additions & 15 deletions session1/intro_to_r_session1_incomplete.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,13 @@ Of course, you can also use Google, Stack Overflow, R-Yammer or the R-user group

### 1.7 Exercises

Open the script intro_to_r_session1_working_script.R and complete the following:

1. Create a new value called y which is equal to 17.

1. Create a new R script file in which you can store all commands you make during this exercise. Save it as 'Intro_R_Exercises.R'.

2. Create a new value called y which is equal to 17.

3. Now multiply y by 78. What answer do you get?
2. Now multiply y by 78. What answer do you get?

4. What does the command "head" do?
3. What does the command "head" do?



Expand Down Expand Up @@ -721,7 +719,7 @@ sepal_length_average <- iris %>%



In the above code, R is taking the 'iris' dataset, grouping it by Species and then (note that the data is "piped" like water into the group_by command using the pipe symbol '%>%' instead of specifying the 'iris' dataset as the first argument within the group_by command), and then outputting the mean length by species. The new mean number of Sepal.Length variable we've decided to call 'ave'. The results are saved into a new dataset called 'sepal_length_average'.
In the above code, R is taking the 'iris' dataset, grouping it by Species (note that the data is "piped" like water into the group_by command using the pipe symbol '%>%' instead of specifying the 'iris' dataset as the first argument within the group_by command), and then outputting the mean length by species. The new mean number of Sepal.Length variable we've decided to call 'ave'. The results are saved into a new dataset called 'sepal_length_average'.



Expand All @@ -731,8 +729,8 @@ The pipe operator simply passes through the object on the left hand side as the
```{r results="hide"}

sepal_length_average <-
summarise(group_by(iris,Species),
ave=mean(Sepal.Length))
summarise(group_by(iris, Species),
ave = mean(Sepal.Length))



Expand Down Expand Up @@ -986,7 +984,7 @@ staff_all <-

```

For more information about the different sorts of joins and other data transformation functions see the 'Data Transformation Cheat Sheet' at: https://www.rstudio.com/resources/cheatsheets/
For more information about the different sorts of joins and other data transformation functions see the 'Data Transformation Cheat Sheet' at: https://rstudio.github.io/cheatsheets/html/data-transformation.html


### 4.2 Exporting data
Expand All @@ -999,7 +997,7 @@ A command to export data into csv format is write_csv from the readr package (th

```{r results="hide"}

write_csv(iris_petals, path = "iris_petals.csv")
write_csv(iris_petals, file = "iris_petals.csv")

```

Expand Down Expand Up @@ -1035,10 +1033,9 @@ There are lots of resources that can help you develop your R knowledge, but belo

+ DataCamp is a website which hosts multiple online courses that teach coding. Their 'Introduction to R' course is free to complete and provides a broader overview in the basic concepts for coding in R. A link to the course can be found here: https://www.datacamp.com/courses/free-introduction-to-r.

+ Another good resource is the 'R for Data Science' online book: [r4ds.had.co.nz/](r4ds.had.co.nz/), written by Hadley Wickham, who is a data scientist at RStudio, who developed the tidyverse package that we introduced earlier. It gives a really good overview of R and how his package works with it.

+ RStudio has also developed a list of 'cheatsheets' which give quick overviews of the functions contained in different packages, which can be quickly referred to: https://www.rstudio.com/resources/cheatsheets/ Some can be accessed directly through the top menu help > Cheatsheets e.g. 'Data Transformation with dplyr'.
+ Another good resource is the 'R for Data Science' online book: [https://r4ds.hadley.nz/](https://r4ds.hadley.nz/), written by Hadley Wickham, who is a data scientist at RStudio, who developed the tidyverse package that we introduced earlier. It gives a really good overview of R and how his package works with it.

+ RStudio has also developed a list of 'cheatsheets' which give quick overviews of the functions contained in different packages, which can be quickly referred to: https://posit.co/resources/cheatsheets/ Some can be accessed directly through the top menu help > Cheatsheets e.g. 'Data Transformation with dplyr'.


Further resources can be found on Saltire Analytical Professions pages (Analytical Professions > Analytical Tools > Analytical Software)
Further resources can be found on Stats group sharepoint site: https://scotsconnect.sharepoint.com/sites/StatisticsGroup-Org-SG/SitePages/R-Resources.aspx
Loading