Data Computing
/
.Every file is contained within a directory. Every directory (except root) is contained with another directory.
The path to a file is the sequence of directories between the root and the file.
The path to a file is the sequence of directories between the root and the file.
In this directory tree …
file1
that is contained within the Jane
directory.Jane
is contained within Home
which is contained within root (/
).The file path is /Home/Jane/file1
file1
. It’s path is /Home/Pablo/file1
./Tmp
. One is /Home/Tmp
. The other is /Home/Jane/Tmp
.Every file on the computer has a unique identifier consisting of the path and the file name.
A similar idea applies to the files available through the Internet.
/
as root, there is a protocol as root, typically http://
or https://
.http://github.com
.http://github.com/dtkaplan/comp110/
.http://github.com/dtkaplan/comp110/index.html
.Every Rmd file is contained within a directory. This is called the working directory.
Example:
/Home
. Within your Rmd file, you can refer to /Home/Jane/file1
as simply Jane/file1
. This is called a relative path./
) are called absolute paths.Relative paths are useful because often you will move an entire directory (and it’s contents) to another computer. The absolute path name will probably change. But the relative path remains the same.
All computer files are sequences of bits. The software that reads a file interprets the bits according to a specified format. There are different standard formats for different purposes.
Some common filename extensions for the sort of web resources you will be using:
.png
for pictures.jpg
or .jpeg
for photographs.csv
or .Rdata
for data files.Rmd
for the human editable text of a document (called R Markdown).html
for web pages themselvesMost people are used to locating a file by using a file browser.
You click on a directory and then can examine the files and sub-directories contained within that directory.
file.choose()
: A handy R function for finding the file path of a file using a file browser:
A typical dialog works like this:
file.choose()
in the R console. (Don’t use file.choose()
in an Rmd file.)/Home/Jane/mydata.csv
.You copy that name into your Rmd file, e.g.
Cases <- read.csv("/Home/Jane/mydata.csv")
Author: Daniel T. Kaplan