gravatar for hasan.ayouby

3 hours ago by

bat_02 <- Batting %>% filter(yearID %in% 1999:2001) %>%

 mutate(pa = AB + BB, singles = (H - X2B - X3B - HR)/pa, bb = BB/pa) %>%
 filter(pa >= 100) %>%
 select(playerID, singles, bb)

bat_02 %>%

 group_by(playerID) %>%
 summarize(avg1 = mean(singles))

# A tibble: 580 x 2

 playerID   avg1

   <chr>     <dbl>

 1 abbotje01 0.169

 2 abbotku01 0.143

 3 abernbr01 0.178

 4 abreubo01 0.153

 5 agbaybe01 0.162

 6 alexama02 0.166

 7 alfoned01 0.161

 8 alicelu01 0.168

 9 allench01 0.165

10 alomaro01 0.186

# ... with 570 more rows

> sum(avg1 > 0.2)
Error: object 'avg1' not found



Source link