Coder Social home page Coder Social logo

Comments (1)

bcongelio avatar bcongelio commented on June 3, 2024

The use of .by_group rather than .group_by is not a typo. It was done by choice. To be clear, both return the same information, but in a differing arrangement.

For example, using .by_group returns the following:

 game_id          week player             position team  offense_pct
   <chr>           <int> <chr>              <chr>    <chr>       <dbl>
 1 2022_01_BAL_NYJ     1 Ben Powers         G        BAL          1   
 2 2022_01_BAL_NYJ     1 Kevin Zeitler      G        BAL          1   
 3 2022_01_BAL_NYJ     1 Morgan Moses       T        BAL          1   
 4 2022_01_BAL_NYJ     1 Patrick Mekari     G        BAL          0.57
 5 2022_01_BAL_NYJ     1 Tyler Linderbaum   C        BAL          1   
 6 2022_01_BAL_NYJ     1 Alijah Vera-Tucker G        NYJ          1   
 7 2022_01_BAL_NYJ     1 Connor McGovern    C        NYJ          1   
 8 2022_01_BAL_NYJ     1 George Fant        T        NYJ          1   
 9 2022_01_BAL_NYJ     1 Laken Tomlinson    G        NYJ          1   
10 2022_01_BAL_NYJ     1 Max Mitchell       T        NYJ          1 

While using .group_by returns the following:

 game_id          week player    position team  offense_pct
   <chr>           <int> <chr>     <chr>    <chr>       <dbl>
 1 2022_01_IND_HOU     1 A.J. Cann G        HOU          1   
 2 2022_02_HOU_DEN     2 A.J. Cann G        HOU          1   
 3 2022_03_HOU_CHI     3 A.J. Cann G        HOU          1   
 4 2022_04_LAC_HOU     4 A.J. Cann G        HOU          1   
 5 2022_05_HOU_JAX     5 A.J. Cann G        HOU          1   
 6 2022_07_HOU_LV      7 A.J. Cann G        HOU          1   
 7 2022_09_PHI_HOU     9 A.J. Cann G        HOU          1   
 8 2022_10_HOU_NYG    10 A.J. Cann G        HOU          0.94
 9 2022_11_WAS_HOU    11 A.J. Cann G        HOU          1   
10 2022_12_HOU_MIA    12 A.J. Cann G        HOU          1  

Because I am interested in seeing the specific combinations of offensive linemen used by a team, per week, I opted to use .by_group to see this, rather than group_by which returns the information on a per-player basis.

from nfl-analytics-with-r-book.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.