Question
If your present working directory is ~/data-projects/project-2, what R command would you use to read the file named fall-data.txt?
Special values in an atomic vector.
NA: Not available / MissingNULL: Does not existNaN: Not a number (e.g. dividing by zero)Inf: InfinityComment character: special character to skip evaluation of remaining characters on a line. R (and Python) use #.
02:30
Vectorized: Operations and functions that can run on an entire vector at once.
Explicit Coersion
as.__(x): sets x to be of type ___
as.double()as.integer()as.character()as.logical()[1] "cat" "dog" "dingo"
Note: the indexing vector is not recycled.
iz buzz poppy
"cat" "dog" "dingo"
iz poppy
"cat" "dingo"
Note: the logical vector should be of the same length.
Question
Write down three methods to generate each vector from the vector z, one for each subsetting method.
z <- c(apple = 2, banana = 4, cherry = 8)
Vector 1:
banana apple
4 2
Vector 2:
cherry cherry
8 8
02:30
You can assign into a subsetted vector to change its contents in place.
apple banana cherry
12 4 12
