You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that there is no forward slash at the beginning of a relative path; if we accidentally typed `"/data/happiness_report.csv"`,
120
+
R would look for a folder named `data` in the root folder of the computer—but that doesn't exist!
121
+
122
+
Aside from specifying places to go in a path using folder names (like `data` and `worksheet_02`), we can also specify two additional
123
+
special places: the *current directory* and the *previous directory*. We indicate the current working directory with a single dot `.`, and
124
+
the previous directory with two dots `..`. So for instance, if we wanted to reach the `bike_share.csv` file from the `worksheet_02` folder, we could
125
+
use the relative path `../tutorial_01/bike_share.csv`. We can even combine these two; for example, we could reach the `bike_share.csv` file using
126
+
the (very silly) path `../tutorial_01/../tutorial_01/./bike_share.csv` with quite a few redundant directions: it says to go back a folder, then open `tutorial_01`,
127
+
then go back a folder again, then open `tutorial_01` again, then stay in the current directory, then finally get to `bike_share.csv`. Whew, what a long trip!
113
128
114
-
So which one should you use? Generally speaking, you should use relative paths.
129
+
So which kind of path should you use: relative, or absolute? Generally speaking, you should use relative paths.
115
130
Using a relative path helps ensure that your code can be run
116
131
on a different computer (and as an added bonus, relative paths are often shorter—easier to type!).
117
132
This is because a file's relative path is often the same across different computers, while a
@@ -139,10 +154,11 @@ difference between absolute and relative paths. You can also check out the
139
154
in R.
140
155
141
156
Beyond files stored on your computer (i.e., locally), we also need a way to locate resources
142
-
stored elsewhere on the internet (i.e., remotely). For this purpose we use a *Uniform Resource Locator (URL)*,
143
-
i.e., a web address that looks something like https://datasciencebook.ca/. \index{URL}
144
-
URLs indicate the location of a resource on the internet and
145
-
help us retrieve that resource.
157
+
stored elsewhere on the internet (i.e., remotely). For this purpose we use a
158
+
*Uniform Resource Locator (URL)*, i.e., a web address that looks something
159
+
like https://datasciencebook.ca/. URLs indicate the location of a resource on the internet, and
160
+
start with a web domain, followed by a forward slash `/`, and then a path
161
+
to where the resource is located on the remote machine. \index{URL}
146
162
147
163
## Reading tabular data from a plain text file into R
0 commit comments