/
index.org
executable file
·93 lines (59 loc) · 5.47 KB
/
index.org
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
#+OPTIONS: title:t date:t author:t email:t
#+OPTIONS: toc:t h:6 num:nil |:t todo:nil
#+OPTIONS: *:t -:t ::t <:t \n:t e:t creator:nil
#+OPTIONS: f:t inline:t tasks:t tex:t timestamp:t
#+OPTIONS: html-preamble:t html-postamble:nil
#+PROPERTY: header-args:R :session R:purrr :eval no :exports code :tangle yes :comments link
#+TITLE: @@html:<span style="font-size: 60%; color: #460606;">@@R workshop for the@@html:</span>@@@@html:<span style="font-size: 75%; color: #460606;">@@ International Ornithological Congress 2018@@html:</span>@@@@html:</span>@@@@html:<br>@@Better practices in R,@@html:<br>@@no more copy-paste, no more loops
#+DATE: {{{time(%B %d\, %Y)}}}
#+AUTHOR: Marie-Hélène Burle
#+EMAIL: msb2@sfu.ca
Most of us biologists do not learn R properly: we do not have a computing science background, we do not necessarily have access to R courses, and when we do, these seldom make use of the latest tools. So, for the most part, we learn R as we go and we become good at problem solving. But do we ever become good at writing good R code?
This workshop focuses on two sets of considerations important for writing better code:
- portability, reproducibility, and readability of code
- functional programming
* Program
** Portability, reproducibility, and readability
Code that is portable, reproducible, and readable is critical when collaborating on projects. At the start of this workshop, we will briefly go over:
- Self-contained projects for portability (as described by [[https://github.com/jennybc][Jenny Bryan]]),
- Clean sessions for reproducibility,
- Standard formatting for better readability (as suggested by [[http://hadley.nz/][Hadley Wickham]]).
The workshop material can be found [[https://prosoitos.github.io/r_workshop_international-ornithological-congress/r_best-practices.html][here]].
** Functional programming
What do you do when you need to apply the same treatment to multiple datasets or multiple variables within a dataset?
Imagine that you have a banding data file and you just wrote some code to transform the raw tarsus length data in a format suitable to analysis. Now, you would like to apply the same code to other variables in your banding data.
Or you wrangled the data in a file by a series of steps. But you have a whole folder full of similar files...
How do you do this?
Copying and pasting code, besides being tedious, is a form of hard coding and is thus prone to errors. Loops provide a much better approach, but they require a lot of code and still involve some level of repetition. They are also hard to read and the goal of your code might not be obvious right away when you go back to it or you give it to someone else. Functional programming is a coding paradigm in which functions are applied to several elements in a vectorized fashion. This makes for compact code that is much clearer and takes advantage of the vector-based nature of R. The src_R[:eval no]{purrr} package (part of the core src_R[:eval no]{tidyverse}) provides a collection of efficient and consistent tools to functional programming in R.
This section constitutes the main part of the workshop. In it, we will focus on:
- A very brief introduction to functional programming,
- How to apply functions to several elements of a list/vector with some of the main src_R[:eval no]{purrr} functions,
The workshop material can be found [[https://prosoitos.github.io/r_workshop_international-ornithological-congress/r_functional-programming_with-answers.html][here]].
** Bonus: src_R[:eval no]{magrittr} less used pipes
A detour to a few of the less used pipes of the src_R[:eval no]{magrittr} package which are so useful when playing in the src_R[:eval no]{tidyverse}.
The workshop material can be found [[https://prosoitos.github.io/r_workshop_international-ornithological-congress/r_magrittr-bonus.html][here]].
* Logistical considerations
** Target audience
- Intermediate R users comfortable with basic data manipulation and simple functions,
- Advanced users familiar with functional programming using the family of the src_R[:eval no]{apply()} functions and interested in discovering the "purrring" way.
** Where and when?
*Date:* Thursday 23
*Time:* 8pm-10pm
*Place:* Vancouver Convention Centre, Rooms 116 & 117
** No fee nor registration
There is no fee nor registration for this event. Simply join us with your laptop ready for the workshop (see below).
** Software requirements
In order to make the best of this workshop, please bring a laptop with the following installed:
- the *latest* R release (3.5.1 /Feather Spray/),
- the *latest* version of the src_R[:eval no]{tidyverse} package,
- and if you usually run R in RStudio, please also make sure to have the *latest* RStudio.
No data file is needed for this workshop.
#+HTML: <br>
#+BEGIN_VERSE
About myself:
I am a PhD candidate in the [[https://www.sfu.ca/biology/wildberg/NewCWEPage/CWEnewTestHome.htm][Centre for Wildlife Ecology]] at [[https://www.sfu.ca/][Simon Fraser University]],
an R Data Peer at the [[https://www.sfu.ca/dean-gradstudies/new_graduate_students/campus_services/research-commons.html][Research Commons]],
a [[https://www.lib.sfu.ca/about/branches-depts/slc/slc-who/grad-facilitators/undergraduate-writing][Graduate Writing Facilitator]] at the [[https://www.lib.sfu.ca/about/branches-depts/slc][Student Learning Commons]],
an admin of the [[http://sciprog.ca/][Scientific Programming Study Group]],
and a certified [[https://software-carpentry.org/][Software Carpentry]] and [[http://www.datacarpentry.org/][Data Carpentry]] instructor.
#+END_VERSE