Use summarise.

library(tidyverse)

df <- tribble(
  ~Condition, ~Subject, ~RESPONSE,
         "A",        1,        77,
         "A",        1,        44,
         "A",        1,         1,
         "A",        2,         1,
         "A",        2,         1,
         "A",        2,        44,
         "A",        3,         1
)

df %>%
  filter(Condition == "A") %>%
  group_by(Subject) %>%
  summarise(
    responses = sum(RESPONSE == 77 | RESPONSE == 44, na.rm = TRUE)
  )
#> # A tibble: 3 x 2
#>   Subject responses
#>     <dbl>     <int>
#> 1       1         2
#> 2       2         1
#> 3       3         0

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top