Skip to content

Commit b5c04b3

Browse files
author
Susan Vanderplas
committed
Add some context to computer basics
1 parent 4c772f9 commit b5c04b3

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

graveyard.qmd

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ Otherwise, launch your system menu (usually with the Super/Windows key) and type
6060

6161
:::
6262

63-
#### File Path Structure
64-
65-
On Windows, file paths are constructed as follows: `C:\Folder 1\Folder_2\file.R`. Paths are *generally* not case sensitive, so you can reference the same file path as `c:\folder 1\folder_2\file.R`. Usually, paths are encased in `""` because spaces make interpreting file paths complicated and Windows paths have lots of spaces.
66-
67-
On Unix systems, file paths are constructed as follows: `/home/user/folder1/folder2/file.R`. Paths are case sensitive, so you cannot reach `/home/user/folder1/folder2/file.R` if you use `/home/user/folder1/folder2/file.r`. On Unix systems, spaces in file paths must be escaped with `\`, so any space character in a terminal should be typed `\ ` instead.
68-
69-
This quickly gets complicated and annoying when working on code that is meant for multiple operating systems. These complexities are why when you're constructing a file path in R or python, you should use commands like `file.path("folder1", "folder2", "file.r")` or `os.path.join("folder1", "folder2", "file.py")`, so that your code will work on Windows, Mac, and Linux by default.
7063

7164
#### Basic Terminal Commands
7265

part-tools/01-computer-basics.qmd

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ When working on code, we will typically assume that the **working directory** (w
228228

229229
@picardiProjectOrganization2024 discusses several common layouts used for research projects.
230230

231-
### Using Paths to Navigate
231+
#### Using Paths to Navigate
232232

233233
File paths can be a bit tricky to construct, but there are a couple of shorthands that help a lot:
234234

@@ -266,6 +266,19 @@ Let's think about a path like `../../../other-dir/other-data.csv`:
266266

267267
:::
268268

269+
#### Constructing File Paths
270+
271+
On Windows, file paths are constructed as follows: `C:\Folder 1\Folder_2\file.R`. Paths are *generally* not case sensitive, so you can reference the same file path as `c:\folder 1\folder_2\file.R`. Usually, paths are encased in `""` because spaces make interpreting file paths complicated and Windows paths have lots of spaces.
272+
273+
On Unix systems, file paths are constructed as follows: `/home/user/folder1/folder2/file.R`. Paths are case sensitive, so you cannot reach `/home/user/folder1/folder2/file.R` if you use `/home/user/folder1/folder2/file.r`. On Unix systems, spaces in file paths must be escaped with `\`, so any space character in a terminal should be typed `\ ` instead.
274+
275+
276+
::: callout
277+
It's easier to just not use spaces in file paths, which you quickly find out when you've had to type paths into the terminal a few times, or if you ever use LaTeX [@xieDontUseSpaces2018].
278+
:::
279+
280+
This quickly gets complicated and annoying when working on code that is meant for multiple operating systems. These complexities are why when you're constructing a file path in R or python, you should use commands like `file.path("folder1", "folder2", "file.r")` or `os.path.join("folder1", "folder2", "file.py")`, so that your code will work on Windows, Mac, and Linux by default.
281+
269282
## System Paths
270283

271284
When you install software, it is saved in a specific location on your computer, like C:/Program Files/ on {{< fa brands windows >}}, /Applications/ on {{< fa brands apple >}}, or /usr/local/bin/ on {{< fa brands linux >}}.

references.bib

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,3 +2223,14 @@ @misc{AllHTTPStatus2023
22232223
urldate = {2025-08-19},
22242224
file = {/home/susan/Nextcloud/Zotero/storage/BBK3S7G6/all_http_status_codes_are_explained.html}
22252225
}
2226+
2227+
@online{xieDontUseSpaces2018,
2228+
title = {Don't Use Spaces or Underscores in File Paths; Use Dashes Instead},
2229+
url = {https://yihui.org/en/2018/03/space-pain/},
2230+
abstract = {Recently I received a few bug reports about the {PDF} generation in R Markdown. Eventually I figured out one of the reasons: spaces in filenames. For example, in rstudio/rmarkdown\#1285, xelatex failed \&hellip;},
2231+
titleaddon = {Blog},
2232+
author = {Xie, Yihui},
2233+
urldate = {2025-08-20},
2234+
date = {2018-03-15},
2235+
langid = {american},
2236+
}

0 commit comments

Comments
 (0)