forked from UEABIO/physalia-R-course-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new 1
163 lines (112 loc) · 7.67 KB
/
new 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
## R programming
Primers: https://posit.cloud/learn/primers/1.2 # functional programming
https://dcl-prog.stanford.edu/index.html
# https://www.tidyverse.org/blog/2023/08/teach-tidyverse-23/
http://modern-rstats.eu/
https://rstudio-education.github.io/hopr/
https://bookdown.org/rdpeng/rprogdatascience/debugging.html
https://rstats.wtf/debugging-r
https://www.r4epi.com/appendix-a-glossary
https://jhudatascience.org/tidyversecourse/wrangle-data.html#functional-programming
## git https://bcullen.rbind.io/courses/workshops/
https://github.com/uopsych/summeR-bootcamp-2020
https://uopsych-r-bootcamp-2020.netlify.app/#schedule
https://book.rwithoutstatistics.com/tables-chapter # tables, parameter reports
https://raps-with-r.dev/part1_conclusion.html # git, functional, literate
https://d-rug.github.io/images/20171026/20171023_DRUG_map_walk.html#1 # presentation function, map, walk
https://mskcc-epi-bio.github.io/Writing-Functions-with-the-tidyverse/#1
https://gt.albert-rapp.de/ # tables
https://psyteachr.github.io/shiny-tutorials/ # shiny
## future work?
https://mdsr-book.github.io/mdsr2e/
##
## https://advanced-r-solutions.rbind.io/functionals.html
Foundations of programming in R: This session serves as an excellent starting point, covering the fundamentals of R programming. Introducing object classes, coding practices, control flow, and writing functions provides a solid foundation for the rest of the course.
Functional programming in R: Functional programming is an important concept, and it's great that you're dedicating a session to it. Covering loops, apply functions, and other functional programming principles will help participants write more efficient and concise code.
Getting the most out of tidyverse: Exploring the Tidyverse is a valuable part of any R course. Since Tidyverse is widely used for data manipulation and analysis, this session will provide participants with practical skills they can directly apply.
Figures and Tables: Data visualization is crucial, and dedicating a session to creating high-quality figures and tables is a great idea. Make sure to cover various visualization techniques and perhaps touch on packages like ggplot2 for advanced visualizations.
Working with Shiny: Shiny is a powerful tool for creating interactive web applications, and introducing it in the course is a good decision. Building Shiny dashboards aligns with the intermediate level and will give participants a practical project to work on.
Reports: Generating reports is an essential skill for data analysts and researchers. Covering reporting packages and customization will empower participants to present their findings effectively.
Github: Version control and collaboration are critical skills, especially in a professional environment. This session will equip participants with the basics of using Github, which is essential for teamwork and code management.
## Session 1: Foundations of Programming in R
Introduction to R and RStudio (30 minutes)
Brief overview of R and its applications in data analysis and programming.
Introduction to RStudio as an integrated development environment (IDE) for R.
Navigating the RStudio interface: scripts, console, environment, and plots.
Objects, Variables, and Data Types (1 hour)
Understanding the concept of objects in R: vectors, matrices, data frames, lists.
Assigning values to variables and creating different data types.
Basic operations with objects: arithmetic, indexing, and subsetting.
Good Coding Practices and Style (1 hour)
Importance of clean and readable code.
Naming conventions for variables, functions, and objects.
Indentation, spacing, and commenting for code clarity.
Introduction to linting tools for code style checking.
Control Flow: If-Else Statements (1 hour)
Introduction to control structures for conditional execution.
Writing if-else statements for decision-making in code.
Handling multiple conditions using nested if-else statements.
Writing Functions in R (1 hour)
Understanding the role and benefits of functions in programming.
Creating custom functions using the function() keyword.
Passing arguments to functions and returning values.
Best practices for function design and documentation.
Hands-On Exercises and Practice (30 minutes)
Interactive coding exercises to reinforce concepts learned.
Applying if-else statements and writing basic functions.
Encouraging participants to practice coding in RStudio.
Summary and Q&A (30 minutes)
Reviewing the key concepts covered in Session 1.
Addressing participant questions and clarifications.
By the end of Session 1, participants should have a solid understanding of fundamental programming concepts in R, including variables, data types, control flow, and function creation. They will also be equipped with good coding practices that will set the foundation for writing clean and maintainable code throughout the course. The hands-on exercises will allow them to apply what they've learned and gain practical experience in R programming.
## Session 2: Functional Programming in R
Introduction to Functional Programming (30 minutes)
Understanding the principles of functional programming.
Contrasting imperative programming with functional programming.
Benefits of functional programming for code readability and maintainability.
For-Loops in R (1 hour)
Introducing the concept of loops for repetitive tasks.
Writing for-loops for iterating over sequences.
Applying loops for tasks like data transformation and calculations.
Discussing scenarios where for-loops are appropriate.
Apply Functions: lapply, sapply, and More (1 hour)
Introduction to apply family functions for iteration.
Understanding lapply() for applying functions to lists.
Using sapply() for simplifying the output of apply functions.
Comparing lapply() and sapply() with for-loops.
Map Functions with purrr Package (1 hour)
Introducing the purrr package for functional programming.
Using map functions (map(), map_lgl(), map_int(), etc.).
Applying map functions to data structures like lists and data frames.
Leveraging the power of functional programming with purrr.
Other Functional Programming Concepts (1 hour)
Chaining operations with the %>% operator (pipe).
Introducing anonymous functions (lambda functions).
Utilizing functionals and custom functions for advanced tasks.
Discussing the advantages of a functional programming approach.
Hands-On Exercises and Practice (30 minutes)
Practical exercises involving for-loops, apply functions, and purrr.
Applying functional programming techniques to real-world examples.
Encouraging participants to practice writing functional code.
Summary and Q&A (30 minutes)
Reviewing the key concepts covered in Session 2.
Addressing participant questions and clarifications.
### Debugging here?
https://data-flair.training/blogs/debugging-in-r-programming/
https://www.geeksforgeeks.org/debugging-in-r-programming/
## Session 3 Tidyverse
Review of Tidyverse Basics (30 minutes)
Quick recap of the key components of the Tidyverse ecosystem.
Emphasizing the principles of tidy data and data manipulation.
Working with Multiple Files and Datasets (1 hour)
Reading data from various file formats (CSV, Excel, etc.).
Combining datasets using functions like bind_rows() and bind_cols().
Merging data with inner_join(), left_join(), and other functions.
Improving Data Manipulation with Data Frames (1 hour)
Exploring advanced data manipulation techniques using dplyr.
Applying complex filtering and transformation using pipes (%>%).
Grouping and summarizing data with group_by() and summarize().
Writing Functions in the Tidyverse Style (1 hour)
Understanding the Tidyverse's consistent syntax and style.
Writing functions using the tidy evaluation framework (quo, !!).
Creating custom functions that integrate seamlessly with the Tidyverse.