I have a numeric vector
vect <- c(0,16,11,132,0,0,0,18,28,245,0,0,55,45,19,30,20,0,0,0,12,0)
There are four series of values not equal to zero.
(16,11,132), (18,28,245), (55,45,19,30,20), (12)
For 1/4 of series (one serie) randomly choosed, I want to add a random integer value between -10 and 10.
For example, if the chosen serie is the second one and the chosen value is -5 the result will be
vect2 <- c(0,16,11,132,0,0,0,13,23,240,0,0,55,45,19,30,20,0,0,0,12,0)
This is an example of only one row, the function will be applied to the entire matrix
Aucun commentaire:
Enregistrer un commentaire