Hi community,
my question is concerning the mean function.
So, if I have a data set, e.g.
data <- data.table(c(1,2,3,4,5,6,7,8,9,10),c(1,6,4,78,2,14,2,95,2,11))
and I want to have the mean of column two, rows five to nine, I write
Average <- mean( data$V2[5:9] )
In a different case, when I want the mean value of all entries in the second column which are greater than two, I go
Average <- mean( data$V2[ data$V2 > 2 ] )
Now, I want both. But how would I get the mean value of rows five to nine of column two where the entries are greater than two, basically combining both of the before mentioned code strips?
In your answer, please consider that I am a total newbie, so maybe dumb it down a little. Thanks in advance!