[R] "Negative length vector" error in simple merge

David Winsemius dwinsemius at comcast.net
Tue Aug 30 18:37:28 CEST 2011


On Aug 30, 2011, at 11:08 AM, DimmestLemming wrote:

> Hi,
>
> I'm trying to take a vector (length almost 2,000,000) and merge it  
> with a
> data frame of the same length. I'm trying to do it solely based on  
> index,
> and not any other factors.
>
> The vector is called "offense", and the data frame is just called  
> "data".

Bad name. There is a function named 'data'.

> I
> went with the simplest option:
>
> merge(data,offense)

It wouldn't make much sense to merge a vector with a dataframe. The  
matching column should not appear any different except perhaps  
shorter. Sounds like you want cbind() rather than merge.

(You really should have posted str(.) on both objects.)

-- 
David.

>
> but it always gives me the same error:
>
> Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :
>  negative length vectors are not allowed
>
> Solutions that haven't worked:
> - Changing offense into a data frame
> - Data doesn't exceed the 2^31 (2 billion) limit for length. When  
> combined
> with offense, it will have about 68 million items total
>
> Thanks! DL
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Negative-length-vector-error-in-simple-merge-tp3778980p3778980.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list