如何在lhs
中只显示一个特殊项目
1 {231050} => {231051} 0.06063479 1.0000000 16.492183
2 {231050,231051} => {275001} 0.05490568 0.9055145 6.576661
3 {231050,275001} => {231051} 0.05490568 1.0000000 16.492183
我想只提取第一行,其中只有一个231050
答案 0 :(得分:3)
class Page1 extends Component {
constructor(props) {
super(props);
this.state = {
openLayer: false,
};
}
_onOpenLayer() {
console.log("fooo");
this.setState({
openLayer: true
});
}
_onCloseLayer() {
this.setState({
openLayer: false
});
}
render() {
let layerNode;
if (this.state.openLayer) {
layerNode = (
<Layer flush={true} closer={true} onClose={() => this._onCloseLayer()} align='right'>
</Layer>
);
}
return (
<Section pad="small" full="vertical" flex={true}>
<div>
<Box direction="row" align="center" justify="end" tag="aside" pad={{horizontal: "large" , between: "small"}} >
<Filter size="medium" colorIndex="brand" onClick={() => this._onOpenLayer()} />
</Box>
{layerNode}
</Section>
);
}
};
有一个arules
函数(请参阅subset
),您可以使用它来绘制符合条件的规则子集 - 例如lhs上的特定项目,最小支持等:< / p>
?arules::subset
答案 1 :(得分:0)
试试这个(假设使用apriori生成规则):
df <- as(rules, 'data.frame')
df$rules <- as.character(df$rules)
lhs <- do.call(rbind, strsplit(df$rules, split='=>'))[,1]
lhs.items <- strsplit(lhs, split=',')
indices <- which(lapply(lhs.items, length) == 1)
special.item <- '231050'
special.indices <- which(grepl(special.item, lhs.items[[indices]]))
selected.rules <- df[special.indices,]
selected.rules
rules support confidence lift
1 {231050}=>{231051} 0.06063479 1 16.49218