How far behind

  • Comments posted to this topic are about the item How far behind

  • Nice question, thanks Steve
    Learned something useful (actually need do do something similar)

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Interesting. I went one further and tried to find the 4577 max yards generically.
    passing.2017$trailingyards <- passing.2017[which.max(passing.2017$yards), "yards2017"] - passing.2017$yards2017
    Thanks for inspiring learning.
    Here's my creation of the dataframe for anyone wanting to play. I'm sure there is a better way, but it's fun to learn.
    rank <- c(1,2,3,4,5)
    player<- c("Tom Brady","Philip Rivers", "Matthew Stafford", "Drew Brees", "Ben Roethlisberger")
    year <- 2017
    yards <- c(4577, 4515, 4446, 4334, 4251)
    passing.2017<-data.frame(rank, player, year, yards)
    colnames(passing.2017) <- c("rank", "player.name", "year2017", "yards2017")

  • An interesting and useful question, thanks Steve.
    I also thank jschmidt 17654 for sharing a perfect general solution, well done. 🙂

    # Create the data frame.
    rank <- c(1,2,3,4,5)
    player<- c("Tom Brady","Philip Rivers", "Matthew Stafford", "Drew Brees", "Ben Roethlisberger")
    year <- 2017
    yards <- c(4577, 4515, 4446, 4334, 4251)
    passing.2017<-data.frame(rank, player, year, yards)
    colnames(passing.2017) <- c("rank", "player.name", "year2017", "yards2017")
    print(passing.2017)

    # Add a new column trailingyards with yards differences.
    passing.2017$trailingyards <- passing.2017[which.max(passing.2017$yards), "yards2017"] - passing.2017$yards2017
    print(passing.2017)

    Results:
    Executing the program....
    $Rscript main.r

    rank   player.name    year2017 yards2017
    1  1    Tom Brady             2017          4577
    2  2  Philip Rivers            2017          4515
    3  3 Matthew Stafford      2017          4446
    4  4   Drew Brees            2017          4334
    5  5 Ben Roethlisberger  2017          4251
    rank   player.name    year2017 yards2017 trailingyards
    1  1    Tom Brady             2017          4577                  0
    2  2  Philip Rivers            2017          4515                62
    3  3 Matthew Stafford      2017          4446              131
    4  4   Drew Brees            2017          4334              243
    5  5 Ben Roethlisberger  2017          4251              326

  • jschmidt 17654 - Wednesday, February 21, 2018 9:00 AM

    Interesting. I went one further and tried to find the 4577 max yards generically.
    passing.2017$trailingyards <- passing.2017[which.max(passing.2017$yards), "yards2017"] - passing.2017$yards2017
    Thanks for inspiring learning.
    Here's my creation of the dataframe for anyone wanting to play. I'm sure there is a better way, but it's fun to learn.
    rank <- c(1,2,3,4,5)
    player<- c("Tom Brady","Philip Rivers", "Matthew Stafford", "Drew Brees", "Ben Roethlisberger")
    year <- 2017
    yards <- c(4577, 4515, 4446, 4334, 4251)
    passing.2017<-data.frame(rank, player, year, yards)
    colnames(passing.2017) <- c("rank", "player.name", "year2017", "yards2017")

    Nice.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply