Wednesday, 15 June 2011

regex - Using gregexpr and accessing elements -



regex - Using gregexpr and accessing elements -

so, used gregexpr, , in homecoming got list back:

b <- gregexpr(a[1],vec)

now, when view b, is:

> b [[1]] [1] 3 9 attr(,"match.length") [1] 3 3 attr(,"usebytes") [1] true

now, wish is, access elements 3 , 9 , store them in variable. however, commands

b[1] b[[1]]

all of them display same. can access first row elements, i.e. 3 , 9?

b[[1]] want. seeing attributes object. can understand more looking @ output of str(b).

relevant reading in ? attributes , the r language definition #attributes.

regex r

No comments:

Post a Comment