-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.Rmd
67 lines (53 loc) · 2.39 KB
/
setup.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
title: ""
---
```{r tangle_R_files, include=FALSE, echo=FALSE}
library(stringr)
# This is moving not copying for some reason
# file.copy("landings.RData",
# "Labs/landings.RData",
# overwrite = TRUE)
library(knitr)
library(rmarkdown)
files <- dir(pattern="^Forecasting.*Rmd$")
files <- str_sub(files,1,-5)
for(fil in files){
infil = paste0(fil,".Rmd")
outfil = paste0("Labs/R_scripts/",fil,".R")
knit(infil, output = outfil, tangle=TRUE)
}
```
```{r render_Rmd_files, include=FALSE, echo=FALSE}
require(stringr)
files <- dir("Labs", pattern="*Rmd$",full.names=TRUE)
files <- str_sub(files,1,-5)
for(fil in files){
infil = paste0(fil,".Rmd")
outfil = paste0(fil,".html")
rmarkdown::render(infil, output_file=outfil)
}
```
## Install R and RStudio
* **R:** Make sure you have the latest version of R.
Go to [https://cran.r-project.org/](https://cran.r-project.org/) and find the download link for your computer system.
* **RStudio:** Install the latest version of RStudio. Get it from [https://www.rstudio.com/products/rstudio/download](https://www.rstudio.com/products/rstudio/download) and install the appropriate one for your OS.
For full set-up instructions including Git and GitHub (optional), go to [full setup](https://rverse-tutorials.github.io/Fish-Forecast-Training-Course/set-up.html)
## Set up a folder and RStudio project for the labs
2. Open RStudio and 'New Project' in the upper right. Select 'From Existing Directory' if you have previously created a folder for the course and select 'New Directory' if you have not.
2. To work on a lab, copy the Rmd or R file to this folder.
3. Next time you open RStudio, you can select your project from the upper right.
## Download FishForecast Package
1. I have created a package on GitHub that will install the packages you need and the data files for the labs. Installing the package will probably take **awhile** as the first time you do it, many packages will be loaded.
```{r get-packages, eval=FALSE}
if(!("devtools" %in% installed.packages()))
install.packages("devtools")
devtools::install_github("Fish-Forecast/FishForecast")
```
The FishForecast package will install the packages listed under "Imports:"
<pre>
```{r get-DESC, results='asis', echo=FALSE}
desc <- RCurl::getURL("https://raw.githubusercontent.com/Fish-Forecast/FishForecast/master/DESCRIPTION")
#desc <- stringr::str_replace_all(desc, "\n", "</br>\n")
cat(desc)
```
</pre>