I have a column with values and want to check if the sum of 5 consecutive values (within a certain range - row 259 to row 272) is > 10 and if at least two out of the 5 values are > 3
This is what I used to come up with the sum of 5 consecutive values. It divides my range into twelve blocks and check each block individually.
data <- read.table("....csv", header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE)
interval <- 5
start <- 259
end <- 272
block<-sapply(start:(end-interval+1),function(x){sum(data[x:(x+interval-1)])})
Now I check if the value of the block is > 10
if ( block [[1]]> 10 ) {
print(paste("block to fulfill the condition is block", 1))
} else if ( block [[2]]> 10 ) {
print(paste("block to fulfill the condition is block", 2))
....
How can I include the condition "two out of 5 values from a block have to be > 3" into my if-clause?