如何根据R中向量中存储的索引选择列?

如何根据R中向量中存储的索引选择列?,r,dataframe,indexing,subset,correlation,R,Dataframe,Indexing,Subset,Correlation,我试图从数据帧中选择相关性大于所需截止值的列。我使用findCorrelation函数将所有相关性较高的索引存储在一个变量中。当我打印这个变量时,我看到索引没有排序。我想知道如何使用此变量从原始数据帧中选择列 correlationMatrix <- cor(cor_numVar[,1:274]) highlyCorrelated <- findCorrelation(correlationMatrix, cutoff=0.5) train[,highlyCorrelated] c

我试图从数据帧中选择相关性大于所需截止值的列。我使用findCorrelation函数将所有相关性较高的索引存储在一个变量中。当我打印这个变量时,我看到索引没有排序。我想知道如何使用此变量从原始数据帧中选择列

correlationMatrix <- cor(cor_numVar[,1:274])
highlyCorrelated <- findCorrelation(correlationMatrix, cutoff=0.5)
train[,highlyCorrelated]

correlationMatrix以下是一个使用
mtcars
dataset的示例:

correlationMatrix <- cor(mtcars[, 2:10])
highlyCorrelated <- caret::findCorrelation(correlationMatrix, cutoff=0.5)
colnames(correlationMatrix)[-highlyCorrelated] #less correlated variables
colnames(correlationMatrix)[highlyCorrelated] #highly correlated variables

correlationMatrix使用lilke:
original\u df[,sort(highlyCorrelated)]
我真的很抱歉。因为我想删除这些高度相关的值,所以我想做一些类似于
original_df[,-sort(highlyCorrelated)]
的事情,同时我通过将这些索引转换为列名称找到了一个解决方案:
要删除