R stuff Flashcards
remove a variable x
rm(x)
special constant for:
missing or undefined data
NA
special constant for:
empty object
NULL
special constant for:
positive / negative infinity?
Inf / -Inf
special constant for:
results that cannot be reasonably defined
NaN
(not a number)
Check if a number eg x is finite?
is.finite(x)
How to combine Values into a Vector or List?
sio
c: Combine Values into a Vector or List
eg
c(1,7:9)
c(1:5, 10.5, “next”)
what are the three common tasks that c() can be used for?
What does c stand for?
- Create a vector.
- Concatenate multiple vectors.
- Create columns in a data frame.
c stands for combine
Check if something:
- is (not) a number?
- is NULL?
- is.nan()
- is.null()
Make a vector that holds true, true, false
- c(TRUE, TRUE, FALSE)
- c(T, T, F)
v4 <- c(v1,v2,v3,”boo”)
What type will the elements be?
all strings
Make a vector with the numbers from 1 to 7
v <- 1:7 # same as c(1,2,3,4,5,6,7)
Make a vector with 0 repeated 77 times
v <- rep(0, 77) # repeat zero 77 times: v is a vector of 77 zeroes
Make a vector with the even numbers from 10 to 20
v <- seq(10,20,2) # sequence: numbers between 10 and 20, in jumps of 2
Make a vector with 1,2,3,1,2,3
v <- rep(1:3, times=2) # Repeat 1,2,3 twice