Repository navigation
Expand file tree
/
Copy pathindex.qmd
More file actions
55 lines (42 loc) · 5.73 KB
/
Copy pathindex.qmd
File metadata and controls
55 lines (42 loc) · 5.73 KB
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
---
title: "Julia and using VSCode"
date: now
author: "Danet and Becks, based on originals by Delmas and Griffiths"
format:
html:
embed-resources: true
title-block-banner: true
---
## Welcome to the Tutorials
This set of tutorials is designed to help you use an integrated coding tool, VSCode, to run experiments with the Bioenergetic Foodweb Model, built in the coding language Julia.
It will cover four core objectives
1. Acquire/install the `Julia` programming language, the Integrated Development Environment called `VSCode`.
2. Learn how to work with `Julia` programming, from installing packages to understanding arithmetic and plotting and data frames
3. Learn how to simulate a simple predator-prey (consumer-resource) model using the `DifferentialEquations` package in Julia
4. Learn how to implement and use the multi-species `EcologicalNetworksDynamics` in Julia
Having done these, you will then be introduced to further complexities and opportunities.
### Moving from R and RStudio to Julia and VSCode
For users of **R** and **RStudio**, **VSCode** and **Julia** can be thought of as the same working team, i.e. **VSCode**/**RStudio** are the text editors that allow you to create a 'rich text' environment from which to run **Julia**/**R**. That being said (as to be expected) there are a few differences in the workflow that it might be worth familiarising yourself with. You can also keep @tbl-cheatsheet handy to help with getting over the first initial stumbling blocks.
**RStudio** users might be familiar with the concept of working with projects (i.e. a way of 'containerising' your work within a specific directory), **Julia** works in a similar manner. Broadly a **Julia** project is much more localised in that any packages that you use (install) are downloaded locally for that specific project (environment), meaning that it is possible to have multiple versions of a package installed for different projects - which is very handy from a reproducibility perspective. The details of the packages (dependencies) that you install are recorded in the `Project.toml` (a records of packages that have been installed and their versions - very useful when sharing code as any user can see exactly what version of a package has been used) and the `Manifest.toml` (all the package dependencies installed - i.e. packages that for a part of the other packages that you have installed) files, these files are machine generated and will update as you add or removed packages while you work so you don't need to worry too much about interacting with them but its good to know what they mean/do. For an **R** specific analogy these files can be thought as the equivalents of the `renv.lock` file generated from the `{renv}` package.
+-----------------------------------------------------------------------------------+-------------------------------+-------------------------+
| action | **R** | **Julia** |
+===================================================================================+===============================+=========================+
| checking current working directory | getwd() | pwd() |
+-----------------------------------------------------------------------------------+-------------------------------+-------------------------+
| install a package |install.package("PACKAGE_NAME")| Pkg.add("PACKAGE_NAME") |
| | | |
| | | `]` add PACKAGE_NAME |
+-----------------------------------------------------------------------------------+-------------------------------+-------------------------+
| call/import a package | library(PACKAGE_NAME) | using PACKAGE_NAME |
+-----------------------------------------------------------------------------------+-------------------------------+-------------------------+
| resolving naming conflicts (functions from different packages with the same name) | PACKAGE_NAME::function() | PACKAGE_NAME.function() |
+-----------------------------------------------------------------------------------+-------------------------------+-------------------------+
| calling column from dataframe | df$COL_NAME | df.COL_NAME |
+-----------------------------------------------------------------------------------+-------------------------------+-------------------------+
| calling the first elements of a dataframe | head() | first() |
+-----------------------------------------------------------------------------------+-------------------------------+-------------------------+
| calling the last elements of a dataframe | tail() | last() |
+-----------------------------------------------------------------------------------+-------------------------------+-------------------------+
: A moving from **R** to **Julia** cheatsheet {#tbl-cheatsheet}
### How to use these tutorials
The simple idea here is to make a Julia script and add the code in these tutorials to your scripts. Make sure you annotate using the `#` symbol, as we do in R Scripts. We suggest that You have a script associated with each section of the table of contents on the left.