A.14 Data Manipulation Functions

cbind          # column bind
rbind          # row bind
head           # first some rows
tail           # last some rows
reshape        # reshape data from wide to long format or vice versa
which          # indices of TRUE in a logical vector of TRUE and FALSE
which.max      # index of maximum value
cut            # cut into intervals
addmargins     # add margins
complete.cases # index of complete cases
na.omit        # omit NAs
expand.grid    # all combinations of columns
outer          # all combinatorial results of a function
unlist         # reverse of list function
stack          # make a vector from multiple vectors
unstack        # reverse of stack function

reshape 은 data manipulation에 매우 유용한데, 활용 예는 1장을 참고한다. 유의할 것은 2022년 6월 현재까지도 tibble data frame은 reshape 이나 기본 문법에 의한 subsetting과는 제대로 작동하지 않는다는 점이다. 활용 예는 1장을 참고한다.