Tutorial 3
Here we’ll practice with programming language environments.
If conda
and python does not apply to you, you may skip the conda
and python portion of the tutorial. If you are taking, have taken, or planning to take a class that uses python it will still be worth practicing and familiarizing yourself with conda environments.
R Environments: renv
- Open up RStudio
- run
getwd()
in the r console, and note the default starting working directory in R when not in a project. - Create an RStudio Project (either from an existing folder, or create a new folder)
- run
getwd()
again and see how the working directory changes - Install the
renv
package (if you do not have it installed) - Note all the current installed R packages you have in the packages panel
- Run the
renv::init()
in the current project (you can also choose tolibrary(renv)
and theninit()
as 2 separate steps - Now note the packages in the package panel
- Install the
palmerpenguins
package in R - Library the
palmerpenguins
package - you should now have access to the
penguins
dataframe - update the lock file with
renv::snapshot()
- Open a new RStudio or close the current project
- You should not be in your project now, and notice the packages listed listed. And notice how the packages change again when you open up the project you just made
Python Environments: conda
- Open up a terminal, you should be in a conda base environment
- Run
python --version
andwhich python
to check the python version you have and which one is actually being used - create a new conda environment with a different python version from the one you currently have in base
- activate this environment
- install jupyterlab and pandas in the new environment
- create an environment.yml file for your new environment. it should only list the packages you explicitly installed (not list dependencies)
- deactivate your python environment