Rune Andersen
Rune Andersen

Reputation: 1

Overview of observations that meet conditions

I have a dataframe of 20.000 observations based on 130 participants. There are several observations from each participant.

I'm calculating the participants' response time.

The average is 25.01.

I want to identify the participants that have an average response time >= 10 seconds.

I can't get my head around this. The ideal output would be a matrix/list of names and their corresponding average response time (but only if it's below 10 seconds).

Upvotes: 0

Views: 21

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226322

Something like:

library("dplyr")
my_data %>% group_by(subject) %>% 
        summarise(avg_response=mean(response_time)) %>%
        filter(avg_response>=10)

You could also use aggregate() and subset() from base R.

Upvotes: 1

Related Questions