Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>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!!!)</p> <pre><code>bbscore = function(x) { scores = c() score = unlist(strsplit(x,split="")) i= 1 while(i&lt;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) } &gt; x [1] "12(10)1X" &gt; bbscore(x) [1] "0" "0" "0" "0" "1" "2" "10" "1" "X" &gt; scores.df = read.csv("GL1995.TXT",header=F) &gt; head(scores.df$V20) [1] 200030300 000000000 000300020 000000010 100100010 001002300 1355 Levels: (11)00033102 00000000 000000000 0000000000 ... 710001001 &gt; scores.df$V20 = as.character(scores.df$V20) &gt; V20.1995.scores = lapply(scores.df$V21, bbscore) &gt; V20.1995.scores = lapply(scores.df$V20, bbscore) &gt; V20.1995.scores[[1]] [1] "2" "0" "0" "0" "3" "0" "3" "0" "0" &gt; V20.1995.scores[[2]] [1] "0" "0" "0" "0" "0" "0" "0" "0" "0" &gt; V20.1995.scores[[3]] [1] "0" "0" "0" "3" "0" "0" "0" "2" "0" </code></pre> <p>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.</p> <p><strong>EDIT:</strong> 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. <code>do.call(rbind,...)</code> won't work. find the longest game and append <code>"X"</code>'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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload