Baby Steps Already

To my great surprise, progress has already been made in R. After playing around with my USISSL dataset in R for a little while, I suddenly remembered the dplyr cheat sheet that I printed about a year ago. Lo and behold! Dpylr was just what I was looking for, at least at this early stage.

Unfortunately, frustration followed for some time because I could not get the dplyr package to install due to a problem with the Rcpp package, which is a dependency of dplyr. I installed R v3.3.3, as this was part of the error message, but that didn't work. Neither did attempting to copy Rcpp from the older R version files on my computer. After spending some time cutting and pasting R error messages into Google in an attempt to find a solution and coming up empty, I realized that the install messages were telling me that Rcpp was in a temporary file. I was able to locate that temporary file, copy it to my R 3.3 file along with the other R packages and voila! It worked! I know!

After that, I attacked the dataset with my particular set of blunt tools. It was a grizzly spectacle, but ultimately I was able to puzzle out a solution to creating the USISSL table that is VERY inelegant. But it works! Any time I can get something of my own creation to work in R is a victory as far as I'm concerned.

I know that there must be much more efficient ways of achieving the same ends, but for now I am pleased with my progress. The code that I wrote involves "manually" composing the data for each state team one at a time. For now, with only 6 teams, this isn't too bad, but for larger leagues (say, a five-a-side league), this approach is cumbersome. There must be a way to write code that will iterate though the dataset (my own functions? something from the "apply" family? some other tools that I can't remember or never knew?) and pull out each state team's points, but that will be a discovery for another day. The same can be said for my final league table, which required multiple lines of code to construct, sort, and label. I'm sure there is a simpler, more efficient way to create this table, but again, a discovery for another day.

For now, here is the USISSL for MLS week 4 as rendered using caveman-level R code. I need to figure out how to title the table with the competition round; perhaps next time...

    State Team Total Points
1   California          206
2        Texas          144
3         Ohio          109
4   New Jersey           96
5     New York           85
6 Pennsylvania           77

It's not pretty, but at least the numbers are the same as the table I made using Excel! Even this small progress has inspired me.


Popular Posts