Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8159873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:03:59+00:00 2026-06-06T18:03:59+00:00

I am working on a research project with baseball data from retrosheet.org. I want

  • 0

I am working on a research project with baseball data from retrosheet.org. I want to create variables for the score of each team in each inning (Vis1, Home1, Vis2, Home2, etc). The problem is that the variable for the box score is coded strangely. Each team has its own variable for the whole game and each inning gets one value. Because leading zeros are cut off a value of “12(10)1X” would mean that a team did not score in the first 4 innings, scored once in the fifth, twice in the sixth, ten times in the seventh, once in the eighth, and they did not have to play the ninth because they had won by that point.

Any advice? I’m at a loss. The () confuse me the most.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:04:01+00:00Added an answer on June 6, 2026 at 6:04 pm

    I’m irish and live in wales and have no clue about baseball but, I think I remember hearing that there can only be a maximum of 9 innings???? (honestly… no clue!!!)

    bbscore = function(x)
    {
     scores = c()
     score = unlist(strsplit(x,split=""))
     i= 1
     while(i<length(score)+1)
     {
       if(score[i]=="(")
       {
         scores = c(scores,paste(score[i+1],score[i+2],sep=""))
         i = i+4
       }
       scores = c(scores,score[i])
       i = i+1
     }
     return(scores)
    }
    > x
    [1] "12(10)1X"
    > bbscore(x)
    [1] "0"  "0"  "0"  "0"  "1"  "2"  "10" "1"  "X" 
    
    > scores.df = read.csv("GL1995.TXT",header=F)
    > head(scores.df$V20)
    [1] 200030300 000000000 000300020 000000010 100100010 001002300
    1355 Levels: (11)00033102 00000000 000000000 0000000000 ... 710001001
    > scores.df$V20 = as.character(scores.df$V20)
    > V20.1995.scores = lapply(scores.df$V21, bbscore)
    > V20.1995.scores = lapply(scores.df$V20, bbscore)
    > V20.1995.scores[[1]]
    [1] "2" "0" "0" "0" "3" "0" "3" "0" "0"
    > V20.1995.scores[[2]]
    [1] "0" "0" "0" "0" "0" "0" "0" "0" "0"
    > V20.1995.scores[[3]]
    [1] "0" "0" "0" "3" "0" "0" "0" "2" "0"
    

    Of course you’ll have to do some furhter manipulations to get them into numbers and deal with X’s and also this will break if there are any other unexpected characters, in addition to being beholden to the assumption of 9 innings.

    EDIT:
    I removed the stipulation for 9 innings and show how to do this for the entire column (assuming that scores you spoke of are indeed the 20th variable in the csv file). Extra porcessing is required for different number of innings. do.call(rbind,...) won’t work. find the longest game and append "X"‘s to the end to make them all the same length? Maybe? I’m not sure but I think this question has been answered at least.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a data mining research project and use code from a big
I want to start working on a big project. I research about performance issues
I'm currently working on a research project that needs to collect checkin tweets from
I'm working on a research project that needs to store complex data as entities
I am working on a research project in big data mining. I have written
I'm working on my first major Cocoa app for an undergraduate research project. The
I am working on a research project that deals with social networks. I have
I am a university student working on a research project that involves migrating a
I am working on a pet project and am at the research stage. Quick
I'm trying to build a QRCodeReader for a project our research group is working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.