R dataframe 遗忘, which 矩阵搜索

时间:2022-05-18 13:59:29

A data frame is used for storing data tables. It is a list of vectors of equal length. For example, the following variable df is a data frame containing three vectors n, s, b.

n = c(2, 3, 5)

s = c("aa", "bb", "cc")

b = c(TRUE, FALSE, TRUE) 

df = data.frame(n, s, b) 
 
a <- data.frame(x = c(1,2,3), y = c(4,5,6), z = c(7,8,9))
 
x <- as.matrix(a)
idx <- which(x > 5, arr.ind=TRUE)