删除R中的特定列

删除R中的特定列,r,R,我正在R中使用findCorrelation函数: highCorr <- findCorrelation(correlations, cutoff = .60,names = FALSE) highCorr如果原始数据是相关矩阵,则可以执行以下操作: library(caret) #findCorrelation comes from this library set.seed(1) #create simulated data for correlation matrix myda

我正在R中使用
findCorrelation
函数:

highCorr <- findCorrelation(correlations, cutoff = .60,names = FALSE)

highCorr如果原始数据是相关矩阵,则可以执行以下操作:

library(caret) #findCorrelation comes from this library
set.seed(1)

#create simulated data for correlation matrix
mydata <- matrix(data = rnorm(100,mean = 100, sd = 3), nrow = 10, ncol = 10)

#create correlation matrix
correlations <- cor(mydata)

#index correlations at cutoff
corr_ind <- findCorrelation(correlations, cutoff = .2)

#remove columns from original data based on index value
remove_corrs <- mydata[-c(corr_ind)]
library(插入符号)#查找的关联来自此库
种子(1)
#为相关矩阵创建模拟数据

mydata是否尝试从数据框/数据表中删除列?如果是这样,数据帧/表的名称
highCorr[highCorr$numbers>cutoff]
将只返回大于您指定的截止值的值。