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
     seq(from, to)
     seq(from, to, by=)
     seq(from, to, length=)
     seq(along)

_D_e_t_a_i_l_s:

     The operator `:' and the first `seq(.)' form generate the sequence
     `from, from+1', ..., `to'. `seq' is a generic function.

     The second form generates `from, from+by', ..., `to'.

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

     The last generates the sequence `1, 2', ..., `length(along)'.

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

_V_a_l_u_e:

     The result is of `mode' `"integer"' if `from' is (numerically
     equal to an) integer.

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_s:

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

     seq(0,1, length=11)
     str(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)
     stopifnot(
      3 == seq(3,3,  by=pi),
      3 == seq(3,3.1,by=pi),
      seq(1,6,by=3) == c(1,4),
      seq(10,4.05,by=-3) == c(10,7)
     )

     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

