Match                 package:GeneR                 R Documentation

_V_a_l_u_e _M_a_t_c_h_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     'Match' returns a vector of the positions of (first) matches of
     its first argument in its second.

     Second must be an element of class segSet (or a numeric matrix
     with 2 columns) ordered and without overlapping segments (function
     or.segSet is designed for this purpose).

_U_s_a_g_e:

     Match(x, a)

_A_r_g_u_m_e_n_t_s:

       x: a vector of positions

       a: an element of class segSet

_V_a_l_u_e:

     a vector of same size a x. Values are indices corresponding to
     element 'a', 0 when no segment found.

_N_o_t_e:

     This can be used for a texture, when we know only regions,
     described by set of segments.

_A_u_t_h_o_r(_s):

     Antoine Lucas

_E_x_a_m_p_l_e_s:

     a = matrix(c(1,30,40,50,60,70,80,110),ncol=2,byrow=TRUE)
     a = or.segSet(a)

     ## show a:
     a

     Match(1:40,a)

     ## texture sample:
     b  = matrix(c(15,18, 28,45,
                        1,10, 15,20, 25,40,
                        17,23, 35,38,100,105,
                        110,120),ncol=2,byrow=TRUE)
     b = or.segSet(b)

     texture = ( Match(1:120,a)>0 ) + ( Match(1:120,b)>0 )*2

     ## change numbers to colors

     texture <- as.factor(texture)
     levels(texture) <- c("red","blue","green","yellow")
     texture <- as.character(texture)

     plot(1:120,rep(1,120),col=as.character(texture))

