I have a very simple question but I cannot find the answer.
I have a data containing 135 observations with 5 variables to describe them. one of them is the "Sample" variable containing three levels: month 0, month 2 and month 4.
The other variable is a value (proportion of gonads)
I would like to create a for loop selecting, for each sample level (month 0, month 2 and month 4), the above-average observations during the sample (month 0, month 2 and month 4).
In other words, for each sample (month 0, month 2 and month 4), I have to average the proportion of gonads, then select the observations greater than this average in each sample.
I manage to create a for loop that answers me, for each sample, if yes or no, its proportion of gonads is greater than the average:
for (sample in unique (data$Sample)) {
print (data$GT[data$Sample == sample]> mean(data$GT [data$Sample == sample]))
}
And r answer :
[1] FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE FALSE TRUE FALSE TRUE TRUE TRUE TRUE
[16] TRUE TRUE TRUE TRUE FALSE TRUE TRUE FALSE TRUE TRUE TRUE TRUE FALSE TRUE TRUE
[31] TRUE TRUE TRUE FALSE TRUE FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[46] FALSE FALSE FALSE
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[16] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[31] TRUE TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE TRUE TRUE TRUE TRUE
[16] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE
[31] FALSE FALSE TRUE TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE
but I am unable to collect the other information on each of these observations (the 4 other variables). In fact, I would like R to show me all the information about "the above-average observations in each sample.". I would like R to show me all the information about "True Value"
Please help me, it drives me crazy !