Re: [R] Support Counting

From: Petr Savicky <savicky_at_praha1.ff.cuni.cz>
Date: Wed, 06 Apr 2011 09:55:09 +0200

On Tue, Apr 05, 2011 at 08:43:34AM -0500, psombe wrote:
> well im using the "arules" package and i'm trying to use the support command.

Hi.

R-help can provide help for some of the frequently used CRAN packages, but not for all. There are too many of them. It is not clear, whether there is someone on R-help, who uses "arules". One of my students is using Eclat for association rules directly, but not from R. I am using R, but not for association rules.

Try to determine, whether your question is indeed specific to "arules". If the question may be formulated without "arules", it has a good chance to be replied here. Otherwise, send a query to the package maintainer. Package maintainers usually welcome feedback.

> my data is read form a file using the "read.transactions" command and a line
> of data looks something like this. there are aboutt 88000 rows and 16000
> different items
> > inspect(dset[3])
> items
> 1 {33,
> 34,
> 35}
> > inspect(dset[1])
> items
> 1 {0, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23, 24,
> 25, 26, 27, 28, 29, 3, 4,5, 6, 7, 8, 9}
>
> So in order to use support i have to make an object of class "itemsets" and
> im kind of struggling with the "new" command.
> I made an object of class itemsets by first creating a presence/absence
> matrix and with something like 16000 items this is really sort of tedious. I
> wonder if there is a better way.
>
> //Currently im doing this
>
> avec = array(dim=400) //dim is till the max number of the item im concerned
> with
> avec[1:400] = 0
> avec[27] = 1
> avec[63] = 1 //and do on for all the items i want
>
> amat = matrix(data = avec,ncol = 400)

Up to here, this may be simplified, if the required indices are stored in a vector, say, "indices". For example

  indices <- c(3, 5, 6, 10)
  avec <- array(0, dim=14)
  avec[indices] <- 1
  amat <- rbind(avec)

or

  amat <- matrix(0, nrow=1, ncol=14)
  amat[1, indices] <- 1
  amat

       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
  avec    0    0    1    0    1    1    0    0    0     1     0     0     0     0

Hope this helps.

Petr Savicky.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 06 Apr 2011 - 07:57:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Apr 2011 - 09:00:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive