I have the following code
n <- 130
pl <- trunc(n/20)
p0 <- 20
pp <- 20 + (0:(pl-1))*p0
With the result of pp
, being: [1] 20 40 60 80 100 120
. Also, I use the same process to create a pe
, according to the following code:
pe <- c(1:8)
for(i in 1:6){
pe[i] <- pl*20+i*20}
pe[7] <- pe[6]+100
pe[8] <- pe[7]+100
Likewise, the result of pe
is: [1] 140 160 180 200 220 240 340 440
.
The above codes are used to calculate values that will be considered to determine the amount of observations extracted from a data file that has 485 observations. However, I have another file that has only 199 original observations and I need to create a looping that creates this list, but with the following constraints: The resulting values of pe should not exceed the number of observations in the file, defined in my algorithm as: (nrow(dados_original))
, and preferably the variables must contain 5 values with a 20-unit interval between them. In the case of the 199 observations, it would only be (140,160,180). In the case of 350 observations would be (140,160,180,200,220,320). Thanks for the suggestions.