Slicing and extracting data Flashcards
1
Q
x[n]
A
nth element
2
Q
x[-n]
A
all but the nth element
3
Q
x[1:n]
A
first n elements
4
Q
x[-(1:n)]
A
elements from n+1 to the end
5
Q
x[c(1,4,2)]
A
specific elements
6
Q
x[“name”]
A
element named “name”
7
Q
x[x>3]
A
all elements greater than 3
8
Q
x[x > 3 & x < 5]
A
all elements between 3 and 5
9
Q
x[x %in% c(“a”,”and”,”the”)]
A
elements in the given set
10
Q
LIST: x[n]
A
list with elements n
11
Q
x[[n]]
A
nth element of a list
12
Q
LIST: x[[“name”]]
A
element of the list named “name”
13
Q
LIST: x$name
A
id
14
Q
x[i, j]
A
element at row i, column j
15
Q
x[i,]
A
row i