Read in files and execute scripts
Exercise Type: Implementation
Instructions
The following exercises are about processing data that you have to read in from a file. For every part of the exercises you are expected to
- Download a data file
- Put the datafile into a specific place
- Modify the path to the file in the code snippet,
- Run the code to produce a plot from the downloaded data!
Part 1
- Download this file to the hard drive: volcano.rds
- Make sure that the file is in the
Downloads
directory (on Windows this is C:\Users<Username>\Downloads) - Modify and run this bit of code until you see a nice plot appearing!
volcano <- readRDS("<path to file, ending with/volcano.rds>")
filled.contour(volcano)
Part 2
- Download this file to the hard drive: normal.txt
- Put the file in the
Desktop
directory (on Windows this is C:\Users<Username>\Desktop) - Modify and run this bit of code until you see a nice plot appearing!
normal <- scan("<path to file, ending with/normal.txt>")
hist(normal)
Part 3
- Download this two files to the hard drive: spiral_x.txt and spiral_y.txt
- Put the files in the same directory somewhere!
- Modify and run this bit of code until you see a nice plot appearing!
# set working directory
setwd("<path to working directory>")
x <- scan("spiral_x.txt")
y <- scan("spiral_y.txt")
plot(x,y, col="#44999911", pch=16, cex=2)