English 中文(简体)
你们将如何用读处理。 R 规则包的交易?
原标题:How would you handle this with read.transactions in R arules package?
  • 时间:2012-04-20 15:08:50
  •  标签:
  • r

I m trying to read a .txt file with the function read.transactions. This is the structure of my file:

1121,1141,1212,1311,1343,2111,2171,2213,2215,2311,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
1111,1112,1126,1145,1146,1181,1213,1441,2122,2322,3311,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
1172,2131,2173,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
1141,1223,1416,2322,2323,112701,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

• 采用这一代法实施:

tr <- read.transactions("disco.txt", format = "basket", sep= , ,rm.duplicates= TRUE)

但我所看到的是这样的东西(inspect(head(tr)):

1 {,      
   1121,  
   1141,  
   1212,  
   1311,  
   1343,  
   2111,  
   2171,  
   2213,  
   2215,  
   2311}  
2 {,      
   1111,  
   1112,  
   1126,  
   1145,  
   1146,  
   1181,  
   1213,  
   1441,  
   2122,  
   2322,  
   3311} 
.
.
.

我的问题是:我如何从这些交易中删除空洞物品? 这一概念后来适用原始算法,以便制定有吸引力的规则。 您是否知道该算法(apriori in R。 能够处理这一问题? 我在我刚才所看到的交易中应用了原算法,但许多交易在装上空箱方面毫无用处。

Many thanks in advance! Regards!

最佳回答

我认为,这里的问题是线索。 因此,我认为,如果你在使用<代码>阅读的新/经修改的文档中把“、”字放在一边,那是最容易的。

工作不是特别的,而是:

library("arules")

temp <- readLines("stack.dat")
for (i in 1:length(temp))
  temp[i] <- gsub(",*$", "", temp[i])
writeLines(temp, "stack_mod.dat")

tr <- read.transactions("stack_mod.dat", format = "basket", sep= , , rm.duplicates=TRUE)

你们是不是这样吗?

问题回答

暂无回答




相关问题
How to plot fitted model over observed time series

This is a really really simple question to which I seem to be entirely unable to get a solution. I would like to do a scatter plot of an observed time series in R, and over this I want to plot the ...

REvolution for R

since the latest Ubuntu release (karmic koala), I noticed that the internal R package advertises on start-up the REvolution package. It seems to be a library collection for high-performance matrix ...

R - capturing elements of R output into text files

I am trying to run an analysis by invoking R through the command line as follows: R --no-save < SampleProgram.R > SampleProgram.opt For example, consider the simple R program below: mydata =...

R statistical package: wrapping GOFrame objects

I m trying to generate GOFrame objects to generate a gene ontology mapping in R for unsupported organisms (see http://www.bioconductor.org/packages/release/bioc/vignettes/GOstats/inst/doc/...

Changing the order of dodged bars in ggplot2 barplot

I have a dataframe df.all and I m plotting it in a bar plot with ggplot2 using the code below. I d like to make it so that the order of the dodged bars is flipped. That is, so that the bars labeled "...

Strange error when using sparse matrices and glmnet

I m getting a weird error when training a glmnet regression. invalid class "dgCMatrix" object: length(Dimnames[[2]]) must match Dim[2] It only happens occasionally, and perhaps only under larger ...

Generating non-duplicate combination pairs in R

Sorry for the non-descriptive title but I don t know whether there s a word for what I m trying to achieve. Let s assume that I have a list of names of different classes like c( 1 , 2 , 3 , 4 ) ...

Per panel smoothing in ggplot2

I m plotting a group of curves, using facet in ggplot2. I d like to have a smoother applied to plots where there are enough points to smooth, but not on plots with very few points. In particular I d ...

热门标签