seq                   package:base                   R Documentation

_S_e_q_u_e_n_c_e _G_e_n_e_r_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Generate regular sequences.

_U_s_a_g_e:

     from:to
        a:b

     seq(from, to)
     seq(from, to, by= )
     seq(from, to, length.out= )
     seq(along.with= )
     seq(from)

_A_r_g_u_m_e_n_t_s:

    from: starting value of sequence.

      to: (maximal) end value of the sequence.

      by: increment of the sequence.

length.out: desired length of the sequence.

along.with: take the length from the length of this argument.

     a,b: 'factor's of same length.

_D_e_t_a_i_l_s:

     The binary operator ':' has two meanings: for factors 'a:b' is
     equivalent to 'interaction(a, b)' (except for labelling by 'la:lb'
     not 'la.lb').  For numeric arguments 'a:b' is equivalent to
     'seq(from=a, to=b)'.

     The interpretation of the unnamed arguments of 'seq' is _not_
     standard, and it is recommended always to name the arguments when
     programming.

     Function 'seq' is generic, and only the default method is
     described here.

     The operator ':' and the 'seq(from, to)' form generate the
     sequence 'from, from+1, ..., to'.

     The second form generates 'from, from+by', ..., up to the sequence
     value less than or equal to 'to'.  Specifying 'to - from' and 'by'
     of opposite signs is an error.

     The third generates a sequence of 'length.out' equally spaced
     values from 'from' to 'to'.

     The fourth form generates the sequence '1, 2, ...,
     length(along.with)'.

     The last generates the sequence '1, 2, ..., length(from)' (as if
     argument 'along' had been specified), _unless_ the argument is
     numeric of length 1 when it is interpreted as '1:from' (even for
     'seq(0)' for compatibility with S).

     If 'from' and 'to' are factors of the same length, then 'from :
     to' returns the "cross" of the two.

     Very small sequences (with 'from - to' of the order of 10^{-14}
     times the larger of the ends) will return 'from'.

_V_a_l_u_e:

     Currently, the default method returns a result of _storage mode_
     '"integer"' if 'from' is (numerically equal to an) integer and,
     e.g., only 'to' is specified, or also if only 'length' or only
     'along.with' is specified.  *Note:* this may change in the future
     and programmers should not rely on it.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     The method 'seq.POSIXt'.

     'rep', 'sequence', 'row', 'col'.

     As an alternative to using ':' for factors, 'interaction'.

     For ':' used in the formal representation of an interaction, see 
     'formula'.

_E_x_a_m_p_l_e_s:

     1:4
     pi:6 # float
     6:pi # integer

     seq(0,1, length=11)
     seq(rnorm(20))
     seq(1,9, by = 2) # match
     seq(1,9, by = pi)# stay below
     seq(1,6, by = 3)
     seq(1.575, 5.125, by=0.05)
     seq(17) # same as 1:17

     for (x in list(NULL, letters[1:6], list(1,pi)))
       cat("x=",deparse(x),";  seq(along = x):",seq(along = x),"\n")

     f1 <- gl(2,3); f1
     f2 <- gl(3,2); f2
     f1:f2 # a factor, the "cross"  f1 x f2

