1
in the R (rstudio)
I have a vector v1 <- c(543, 543, 543, 675, 675, 675, 675, 22, 22, 22, 90, 90, 87, 876, 867)
.
I’d like to get a vector vr
which represented the count of v1
(increasingly 1:n
) of the repeating numbers.
In relation to the previous vector (v1
) for example: vr <- c(1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 1, 1, 2)
.
From now on, thank you very much!
Try the function
?table
. But the countdown doesn’t give the question.– Rui Barradas
I just found out:
– Yuri Gelsleichter
I have just figured out how to do the task: https://answall.com/questions/357/howto count-o-n%C3%Bamero-cumulative-to-occur%C3%Aancias-to-one-element-to-one-vector/358#358 com: "count <- ave(rep(1, length(x))), x, FUN=cumsum)"
– Yuri Gelsleichter
Thank you very much!
– Yuri Gelsleichter