-
Notifications
You must be signed in to change notification settings - Fork 0
/
libs.qmd
35 lines (22 loc) · 1.95 KB
/
libs.qmd
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
---
title: "Packages & Libraries"
engine: knitr
---
## Installation versus Loading
Packages must first be _installed_ before they can be _loaded_. Installing a package is equivalent to going to a hardware store and buying a pre-made set of tools whereas loading that package is more like retrieving a set of tools that you already own and putting them in your work space so they are available to use. <u>All sections of this website assume you have already installed the needed packages</u> so consult the [package installtion instructions](https://njlyon0.github.io/collab_bilingualism/#package-installation) on the home page of the site if you have not already done so.
Note also that "package" and "library" are functionally interchangeable for our purposes though it is more common to say that packages are installed and libraries are loaded.
## Library Loading
Assuming you've already installed the needed [{{< fa brands python >}} Python]{.py} _and_ [{{< fa brands r-project >}} R]{.r} packages, you can now load them.
:::panel-tabset
## [{{< fa brands r-project >}} R]{.r}
[{{< fa brands r-project >}} R]{.r} libraries are loaded with the `library` function.
```{r r-libs, warning = F, message = F}
library(tidyverse)
```
## [{{< fa brands python >}} Python]{.py}
[{{< fa brands python >}} Python]{.py} libraries are loaded with the `import` statement and can be "aliased" into simpler names with `as` at the same time. Note that common libraries (like `pandas`) have broadly-accepted abbreviations that are almost always used (like `pd` in the case of `pandas`).
```{python py-libs}
import pandas as pd
```
:::
With that, you're all done loading libraries! Note however that you will need to re-load your libraries every time you quit and re-open your IDE (<u>I</u>ntegrated <u>D</u>eveloper <u>E</u>nvironment) such as [Conda]{.py} or [RStudio]{.r}. Restarting your session will also necessitate re-loading your libraries. That said, you only need to install packages _once!_