-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08-FinalIndications.Rmd
52 lines (40 loc) · 5.09 KB
/
08-FinalIndications.Rmd
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
# Final indications {#finalindications}
## Use Projects
To organize your work, not only in **RStudio**, but also on hard drive you should use projects. It is extremely easy in this IDE. Just click button -- *Create new project* -- choose *New Directory* and type of project you need. **RStudio** will take care of everything for you. Later you can easily add files of sub-folders with specifying content into your project and use relational links. Also, using projects makes easy to maintain clean global environment, which beginners often tend to underestimate and than they run into troubles.
## Use RMarkdown
To make your work more reproducible, and also to make nice looking output (in html or PDFs) it is a good idea to work in RMarkdown files instead of RScripts. The syntax of **RMarkdown** is nearly identical to original **Markdown**, but allows you to execute and store **RCode**. You can find [RMarkdown introduction here](http://rmarkdown.rstudio.com/articles_intro.html). There is also nice [cheat sheet](https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf) which contains all commands you will need. As there is strong pressure to make research and science more open and reproducible, it is strongly advised that you work with proper tools to do it like **RMarkdown** or **Project Jupyter**. If you want to learn more, there is very nice [guide by British Ecological Society](https://www.britishecologicalsociety.org/wp-content/uploads/2017/12/guide-to-reproducible-code.pdf) you should read.
Also, you need to know that to make output in PDFs format, you will first need to install **LaTeX** distribution. There are tons of tutorials how to do it on different operating system. The thing is that even you don't use **LaTeX** directly, **R** uses it *under the hood* to (oversimplifying) to convert **RMarkdown** to PDFs. For **Linux** users, one piece of advice is to install *full* distribution instead of *base*, it take more time and disk space, but will save you frustration of installing additional packages later.
## Use .rds files
Usually we work with plain text files like csv or tsv in **R**. However, there is also a highly valuable format of files called rds, that makes work even more pleasant. It not only preserves all classes of variables, but also takes less space than plain text file, due to compression algorithms. Also when using `saveRDS()` you don't need to define hundreds of parameters, just name of object you want to save and its file name. The downside is that it is format to use directly with **R** and won't work with other programs.
## Nice resources you SHOULD read
There is few hundred of books relating more or less to work in **R**. There is also a huge number of blogs, web pages and other on-line resources that helps with work in **R**. Here you will find some of them that I find very useful in everyday work with R and statistics.
***
\begin{center}
\begingroup\Large
R and its packages
\endgroup
\end{center}
***
* [Basic Transformations and Explorations in the Tidyverse](https://annamarbut.blogspot.de/2018/02/basic-transformations-and-explorations.html)
* [R Graphic CookBook free on-line version](http://www.cookbook-r.com/Graphs/)
* [Advanced R free on-line version](https://adv-r.hadley.nz/)
* [Collection of R cheat sheets](https://www.rstudio.com/resources/cheatsheets/)
* [R Weekly -- Collection of best news from data science world](https://rweekly.org)
***
\begin{center}
\begingroup\Large
Statistics, programming and modeling
\endgroup
\end{center}
***
* [RECONlearn -- free resources on epidemiology](https://reconlearn.netlify.com)
* [Norm Matloff's blog discussing issues with statistics and data science](https://matloff.wordpress.com/)
* [Rosetta Code -- a repository for code to solve large number of problems with tens of different programming languages](https://rosettacode.org/wiki/Rosetta_Code)
## Solving problems
As you saw, **R** can be used for many different purposes, like statistics or modeling, whiteout any programming knowledge. However, the more you will work with it, the sooner you will find how programming skills, can help you will daily work. Of course some problems in the beginning will be to complicated to solve quickly, but spending time on finding solution will save you lots of time in future. Also, if you follow few simple rules, you will work faster and be less frustrated. This rules make simple workflow:
* take some time to analyze the problem
* divide your problem into small pieces
* start with solving piece that you know (or are very close to) solve with least effort
* don't be afraid to ask or look into web for solutions
* take all the small pieces and put them together
Remember -- it is better to do something than do nothing. Even if you are stuck with something, you will still benefit from solutions for smaller pieces of your problem, that you managed to find. In the beginning try to think about robustness and speed of your code, but do not seek for best optimized code at all cost. Sometimes it's just not worth spending half an hour to make your code faster by 1 second. The more you will read, the more ideas about how to write best code you will get.