[R] Best way to store negative indexes
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Wed Jul 28 09:14:43 CEST 2004
StephaneDemurget <demurget at aleks.com> writes:
> Hi,
>
> I'm trying to figure out how to properly construct a graph of
> frequencies of a difference between 2 values, that is | i | - | j |.
> I'd like to know the best way to store the actual data because of
> course doing my_vector[i -j] will not work because the index could be
> negative.
>
> I know there's no hash table so what's the best solution,
> simplicity-wise ? Use a list of pair of values {index, i - j} ? Or can
> I somehow use negative index, perhaps using 0array ? Any help would be
> appreciated :)
(i and j are integer vectors, right?)
How about this:
f <- i - j
f <- factor(f,levels=min(f):max(f))
table(f)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list