小编ntr*_*rax的帖子

使用inspect()函数发生R错误

我的目标是应用文本挖掘的关联规则.

我有这个字符串样本:

sample.word = c("abstracting","abstracting workflow","access control","access information","access methods","access patterns","access permissions","access to government information","accountability","acetamides")
Run Code Online (Sandbox Code Playgroud)

比我制作一个所有值为0的矩阵

incidence.matrix_sample <- matrix(0, nrow=5, ncol=length(sample.word))
Run Code Online (Sandbox Code Playgroud)

我添加字符串作为矩阵列

colnames(incidence.matrix_sample) <- sample.word
Run Code Online (Sandbox Code Playgroud)

现在我在使用pmatch函数出现在文档中的术语列中放入1个值(documents.ids [[i]]是一个id为文档的向量)

for(i in 1:(dim(incidence.matrix_sample)[1]))
{
  incidence.matrix_sample[i, pmatch(documents.ids[[i]], sample.word)] <- 1
}
Run Code Online (Sandbox Code Playgroud)

我尝试继续将矩阵转换为itemMatrix,然后作为事务(使用as(my.matrix,"transactions")函数)但是当我尝试检查规则时,我得到相同的错误:

incidence.matrix_sample <- as(incidence.matrix_sample, "itemMatrix")
incidence.matrix_sample <- as(incidence.matrix_sample, "transactions")
inspect(incidence.matrix_sample)
Run Code Online (Sandbox Code Playgroud)

结果是:

Errore in UseMethod("inspect", x) : 
  no applicable method for 'inspect' applied to an object of class "c('matrix', 'double', 'numeric')"
Run Code Online (Sandbox Code Playgroud)

以及使用先验函数进行入射的相同问题.matrix_sample

Errore in UseMethod("inspect", x) : 
  no applicable method for 'inspect' applied to an …
Run Code Online (Sandbox Code Playgroud)

r matrix text-mining arules

2
推荐指数
1
解决办法
5829
查看次数

在d3js事件上执行React js函数

我是新来的。单击d3js组件时,我需要调用react js函数。

我在React组件中有一个d3js条形图。在同一组件中,我有以下方法:

handleClick: function(data){
    this.props.onClick(data);
},
Run Code Online (Sandbox Code Playgroud)

单击d3js时,我需要调用此函数:

var g = svg.selectAll(".arc")
    .data(pie(data))
    .enter().append("g")
    .on("mouseover", mouseover)
    .on("mouseout", mouseout)
    .on("click", function(d) {
    this.handleClick(); // my react method
   })
Run Code Online (Sandbox Code Playgroud)

但这不起作用。我在chrome中的输出是这样的:

this.handleClick is not a function
Run Code Online (Sandbox Code Playgroud)

怎么了?

d3.js reactjs

1
推荐指数
1
解决办法
2605
查看次数

标签 统计

arules ×1

d3.js ×1

matrix ×1

r ×1

reactjs ×1

text-mining ×1