Classwork 4
Finding and Copying an Absolute Pathname
Find a downloaded file in Windows or macOS, copy its absolute pathname, and paste it into a text editor.
If you use RStudio on your local computer, you need to know how to find and copy a file’s absolute pathname. The pathname tells R exactly where the file is stored.
An absolute pathname lists every folder from the top of the computer’s file system to the file itself.
Copy an absolute pathname
Windows
- Open File Explorer and find the file.
- Right-click the file and choose Copy as path.
- If that command is hidden, hold Shift while right-clicking.
- Paste the copied pathname where you need it.
Example copied pathname
"C:\Users\Alex\Downloads\custdata_rev.csv"
Mac
- Open Finder and find the file.
- Select the file and press Option + Command + C.
- Or hold Option, right-click, and choose Copy “custdata_rev.csv” as Pathname.
- Paste the copied pathname where you need it.
Example copied pathname
/Users/Alex/Downloads/custdata_rev.csv
Note
When entering a Windows pathname in R, use forward slashes (/) or double each backslash (\\).
Mini exercise
TipGoal
Retrieve a downloaded file’s exact location instead of typing it by hand.
- Download
custdata_rev.csvfrom Brightspace. - Find the downloaded file in File Explorer (Windows) or Finder (Mac).
- Copy its absolute pathname using the method above.
- Paste the pathname into any text editor, such as Notepad, TextEdit, or an RStudio script.
- Check that the pasted pathname ends with
custdata_rev.csv.
Your pasted text should resemble:
- Windows:
C:\Users\...\Downloads\custdata_rev.csv - Mac:
/Users/.../Downloads/custdata_rev.csv
