Another way to do it (a more or less straightforward translation of what you
said):
fun <- function(x) {
xp <- c("", x)[-(length(x)+1)] # to get the "previous
element of x"
x[1] <- if(x[1]=="i") "l" else x[1]
x <- ifelse(x == "i" & xp == "c", "l", x)
x <- ifelse(x == "i" &
Thanks a lot, it works perfectly .
Bye
Paul
jholtman wrote:
>
> Is this what you want:
>
>> x
> cola colb
> 11c
> 21i
> 31i
> 41c
> 52i
> 62c
> 72c
> 82i
> 92i
>> # generate run lengths
>> z <- rle(x$colb)
>> # calculat
Is this what you want:
> x
cola colb
11c
21i
31i
41c
52i
62c
72c
82i
92i
> # generate run lengths
> z <- rle(x$colb)
> # calculate offset of each starting sequence
> offsets <- head(cumsum(c(1, z$lengths)), -1)
> # now deter
Hello every body,
I am quite a new user of R so I beg your pardon for this naive question and
the lake of syntax with wich I ask it:
I have a data frames like this:
colacolb
1 c
1 i
1 i
1 c
2 i
2 c
2 c
2 i
2 i
...
1
I would like ,for
4 matches
Mail list logo