[R] "Negative length vectors are not allowed" error
Michael Hahsler
mhahsler at lyle.smu.edu
Tue Jan 20 16:27:31 CET 2015
Dear Kim,
This seems to be an arules problem. More specifically in the subset
function. I will investigate and fix this as soon as possible. You can
use the following code in the meanwhile:
rr <- rhs(ruleset) %pin% "Product="
inspect(ruleset[rr])
Regards,
Michael
On 01/20/2015 04:55 AM, Kim C. wrote:
> Additionally, maybe it's interesting to note that I remember that I
> first also tried the apriori function but with support = 0.001 (the
> rest remains the same). It gave me the negative length vector error as
> well but then I thought to update the packages and it seemed like it
> worked because the inspect with subset gave the results. But with 0.0005
> it still gives me that error.
>
>
>
> Dear Martin,
>
> Thanks for your fast reply. Sorry about the formatting of the previous
> email. I actually tested it before sending and it came fine when sending
> to my own account but when I send it to the r-help email address it
> seemed like the formatting got lost.
>
> I can actually send you the project of R I am working in because for
> this experiment I am only using the Contoso DWH testdata from Microsoft.
> The R project is too big to include in the attachment, so you can
> download it from my dropbox via this link:
> https://www.dropbox.com/s/lry1v7ka2env5xf/Example.RData?dl=0
>
> I see I a made a small mistake in my description, so I will rewrite it
> shortly in steps:
> 1. ruleset <- apriori(sales, parameter=list(support=0.0005,
> confidence=0.1, minlen=2)) This gives 780379 rules.
> 2. inspect(subset(ruleset, subset=rhs %pin% "Product="))
> 3. just inspect(ruleset) does work. When finishing displaying the
> 780379 rules, it also show me this message:
> Warning message:
> closing unused RODBC handle 1
>
> If I understand the last part correctly, I should add Michael Hahsler's
> email address to the BCC. Otherwise, my apologies.
>
> Thanks again,
>
> Kim
>
> From: minorthreatx at hotmail.com
> To: maechler at stat.math.ethz.ch
> Date: Tue, 20 Jan 2015 11:27:44 +0100
> CC: r-help at r-project.org; mhahsler at lyle.smu.edu
> Subject: Re: [R] "Negative length vectors are not allowed" error
>
> <br>If the email is still unreadable, please look at the attachment email.txt. <br>Dear Martin,<br><br>Thanks for your fast reply. Sorry about the formatting of the previous email. I actually tested it before sending and it came fine when sending to my own account but when I send it to the r-help email address it seemed like the formatting got lost. <br><br>I can actually send you the project of R I am working in because for this experiment I am only using the Contoso DWH testdata from Microsoft. <br>The R project is too big to include in the attachment, so you can download it from my dropbox via this link: <br><a href="https://www.dropbox.com/s/lry1v7ka2env5xf/Example.RData?dl=0" target="_blank">https://www.dropbox.com/s/lry1v7ka2env5xf/Example.RData?dl=0</a><br><br>I see I a made a small mistake in my description, so I will rewrite it shortly in steps: <br>1. ruleset <- apriori(sales, parameter=list(support=0.0005, confidence=0.1, minlen=2)) This g
ives 780379 rules. <br>2. inspect(subset(ruleset, subset=rhs %pin% "Product="))<br>3. just inspect(ruleset) does work. When finishing displaying the 780379 rules, it also show me this and this message: <br>Warning message:<br>closing unused RODBC handle 1 <br><br>If I understand the last part correctly, I should add Michael Hahsler's email address to the BCC. Otherwise, my apologies. <br><br>Thanks again, <br><br>Kim <br>----------------------------------------<br>> From: maechler at stat.math.ethz.ch<br>> Date: Tue, 20 Jan 2015 10:30:34 +0100<br>> To: minorthreatx at hotmail.com<br>> CC: r-help at r-project.org; maechler at stat.math.ethz.ch<br>> Subject: Re: [R] "Negative length vectors are not allowed" error<br>><br>><br>> > Hi all, I have a question concerning an error that occurs when using the inspect() function on a set of rules made by the apriori function from the arules package. I have a dataset with 12 million records.
It contains some basic sales information (such as product, customer data). I want to use the apriori function from the arules package on it: ruleset <- apriori(sales, parameter=list(support=0.0005, confidence=0.1, minlen=2))It gives me 780379 rules. I want to have that much rules on purpose, so hence the parameters being so low (I guess you can reproduce this problem with any large dataset and low settings for support and confidence). But then I want to check out the rules with inspect. It has a subset because I'm only interested in rules with the attribute Product in the rhs. inspect(subset(ruleset, subset=rhs %pin% "Product="))Then this error occurs: Error in inspect(subset(sales3ruleset, subset = rhs %pin% "Product=")) :<br>> > error in evaluating the argument 'x' in selecting a method for function 'inspect': Error in .Call("R_or_ngCMatrix", x at data, y at data, PACKAGE = "arules") :<br>> > negative length vectors are not allowedI looked around and apparently that part a
bout "negative length vectors are not allowed" means that you want to create a vector that is larger than 2^31. How can you get around this limit? Or how can I make the inspectfunction work in this case?Thanks in advance!Kim<br>> Dear Kim,<br>><br>> if you learned to post (i.e. write that e-mail) in plain text,<br>> the above would look more humane..<br>><br>> Still, I was able to decipher it and you are right in that<br>> you hit a limitation of the current setup which may well<br>> be linked to the Matrix package which I maintain, and on which<br>> 'arules' depends.<br>><br>> Can you please try to find a reproducible example [with randomly<br>> generated data; i.e., you'd use set.seed(), runif(), rpois(),<br>> rmultinom(), rnorm(), ...] so we,<br>> the maintainer of 'arules' Michael Hahsler (BCC'ed: use<br>> maintainer("arules") to find such an e-mail address),<br>> and myself can look if and how that limitation might be lifted.<br>>
;<br>> Best regards,<br>> Martin Maechler, ETH Zurich<br>
>
>
> ______________________________________________ R-help at r-project.org
> mailing list -- To UNSUBSCRIBE and more, see
> 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.
--
Michael Hahsler, Assistant Professor
Department of Engineering Management, Information, and Systems
Department of Computer Science and Engineering (by courtesy)
Bobby B. Lyle School of Engineering
Southern Methodist University, Dallas, Texas
office: Caruth Hall, suite 337, room 311
email: mhahsler at lyle.smu.edu
web: http://lyle.smu.edu/~mhahsler
More information about the R-help
mailing list