我想制作一个数据帧,该数据帧的条目仅低于某个定义的阈值并与b列进行比较,这样就排除了条目“ OP2775iib SAV OP2958i_b POR”。
我尝试了以下代码:
less_than_threshold <- data.frame(which(data[data$b < threshold]))
但是它返回并且我无法完全把握的错误:
[.data.frame
中的错误(pairwise_ind_Mdists,pairwise_ind_Mdists $ Mdist <:
未定义的列已选择
这是我正在使用的数据的示例:
data <- data.frame(a = c("OP2775iia MOU OP2775iib SAV","OP2775iia MOU OP2958i_a COM","OP2775iib SAV OP2958i_a COM","OP2775iia MOU OP2958i_b POR","OP2775iib SAV OP2958i_b POR"),
b = c(4.9022276,3.8867063,3.0126033,5.0261763,6.3745697))
threshold <- 6.3745697
我想要一个数据框,其中包含原始数据集中的所有条目,但最后一个条目为“ OP2775iib SAV OP2958i_b POR”
答案 0 :(得分:0)
我建议使用dplyr软件包
var matchScoreData = {
"tbl_FallOfWicket": [{
"pk_fallWicketID": 119,
"fk_matchID": 133137,
"fk_teamID": 141065,
"fk_dismissTypeID": 3,
"fk_dismissPlayerID": 969155,
"run": 40,
"wicket": 1,
"over": "5.1",
"inning": 1,
"createdDate": "2018-08-18T03:06:12+0000",
"modifiedDate": "",
},
{
"pk_fallWicketID": 120,
"fk_matchID": 133137,
"fk_teamID": 141065,
"fk_dismissTypeID": 1,
"fk_dismissPlayerID": 939721,
"run": 88,
"wicket": 2,
"over": "9.5",
"createdDate": "2018-08-18T03:06:12+0000",
"modifiedDate": "",
"inning": 1
}
]
};
var data = matchScoreData.tbl_FallOfWicket;
matchScoreData.tbl_FallOfWicket.forEach(element => {
if (element.hasOwnProperty("createdDate")) {
delete element["createdDate"];
}
});
console.log(data);