first rework of project setup chapter#106
Conversation
|
|
||
| Where: | ||
|
|
||
| - _read-only (RO)_: not edited by either code or researcher |
There was a problem hiding this comment.
I am not so sure about that. Data is usually updated, extended or even fully revised (e.g. an experiment that did not go well).
I like the distinction between human-writeable and project-generated. Although I would also rename the latter to "output files" or "generated files" ...
There was a problem hiding this comment.
I think it's more about the principle, in that there are some folders that may only be read-only? It doesn't necessarily have to be the data directory. It can be another one. Or perhaps the raw data directory.
|
|
||
| - **Relative paths** specify the location of a file or directory relative to the current working directory (e.g., `./data/file.csv`). If you’ve structured your project as a self-contained directory, the root of that directory should be your working directory. Relative paths are portable and reproducible, provided the working directory remains consistent. | ||
|
|
||
| In R, you can further ensure a consistent working directory by using an R Project File (.Rproj), which automatically sets the working directory to the project root. |
There was a problem hiding this comment.
| In R, you can further ensure a consistent working directory by using an R Project File (.Rproj), which automatically sets the working directory to the project root. | |
| Let's inspect the following example file structure and some best parctices for R, Matlab and python. | |
| ```sh | |
| my_project/ | |
| │ | |
| ├ data/ | |
| │ file.csv | |
| │ | |
| └ script.py |
Python
Open the folder my_project in your Development environment (IDE), e.g. Jupyter Notebooks or PyCharm (see some suggestions below.). You can address the csv file like this:
import pandas as pd
df = pd.read_csv("data/file.csv")Since the working directory of your IDE is your project folder, the compiler will find the data automatically.
R
In R you can use RStudio as IDE, simply create File → New Project → New Directory
data <- read.csv("data/file.csv")Matlab
Similar as in R you can set up a project folder in Matlab and use:
data = readtable("data/file.csv");
In general IDEs help you to make use of relative paths:
| Language | Beginner IDE | Feature |
|---|---|---|
| Python | Visual Studio Code | workspace folder |
| R | RStudio | built-in projects |
| MATLAB | MATLAB | current folder |
|
|
||
| If you want to retroactively apply a naming convention, you can use your programming language of choice or the command line. | ||
|
|
||
| ## Absolute vs. Relative Paths |
There was a problem hiding this comment.
I am not sure whether this chapter fits here or better in book/chapters/reusability.qmd
There was a problem hiding this comment.
I revisited the reusability chapter and I think we could keep the stuff about paths here, so people can focus on the concept of functionalizing/modularizing code in that section. But you can let me know if you think otherwise!
chStaiger
left a comment
There was a problem hiding this comment.
Many thanks this looks good.
I gave some inspiration to extend the relative paths section a bit and I think this section can be moved or at least referenced in the resuability section of the book.
I would be fine either way. Doing the deep dive here and mentioning it in the resuability section; or the other way around.
|
@chStaiger, I made some changes and did a quick update of the slides! Could you do a final review? And we can merge after the workshop, don't want to break something 😅 |
There was a problem hiding this comment.
The video needs to be removed
| ::: | ||
|
|
||
| ## Being reproducible | ||
| ## Let's Git Started! |
chStaiger
left a comment
There was a problem hiding this comment.
I fixed the layout for the slide that only show code blocks.
Thank you for adjusting the contents. Approved by me.
Hi! I've made a first attempt at updating the Project Setup chapter. There's still some things to be cleaned up, both in the chapter and the slides. I'm happy to get feedback before I get to the second round of edits.