Skip to content
Prev 275795 / 398506 Next

question R regarding consecutive numbers

Are you looking for something like the following?  ifactor()
is like factor but assumes that x is integral and that levels
should be {1, 2, ..., max(x)} with no gaps.
1 2 3
  1 3 0 1
  2 1 0 0
  3 1 0 0
  4 2 0 0
  5 2 0 0
  6 1 0 0
  7 0 0 0
  8 0 0 0
  9 2 0 0

Also note that tbl["2","3"] does not mean the same as tbl[2,3],
although if you use the ifactor function as above they will refer
to the same element.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com