I have a massive csv file that responds to the following minimized structure:
Here the data table inserted:
Ronda Tratamiento
5 A
6 A
7 A
6 A
7 A
3 B
4 B
5 B
6 B
7 B
6 C
7 C
6 C
7 C
5 C
6 C
7 C
6 B
7 B
The round column contains values sorted from an arbitrary value to 7. I would like to eliminate from the round column all the rows that contain a numeric value for round greater than the numeric value of the previous row. Or in other words, keep only the rows containing the first value in which the growing series up to 7 starts.
For example, in the example provided, get something like this:
Ronda Tratamiento
5 A
6 A
3 B
6 C
6 C
5 C
6 B
I was trying to create an additional column with the idea of later deleting rows. But I am not familiar with these operations in R. Surely there is a much more effective and direct method. Copy, in any case the efforts:
v <- c()
data$Round <- as.numeric(data$Round)
for (i in seq(1:(nrow(t)))) {
v <-c(v, ifelse(t[i+1,5]> t[i,5], 1,0))
}
t$keep <- v
t<- t[!(t$keep==0),]
Thanks for the help,