Sports Analytics in Practice with R. Ted Kwartler
Чтение книги онлайн.
Читать онлайн книгу Sports Analytics in Practice with R - Ted Kwartler страница 14

Besides the ability to execute functions drawing from across multiple specialized languages R has other positive benefits. For example, R has a well-developed support community. Often when you are presented with an error or unknown operation, a simple online search will identify the solution. Additionally, R is optimized for statistics. Although python, a competing and more-diverse language has similar functionality, there are still differences between the two languages. For example, some machine learning-tuning parameters are better executed in R, the simple creation of dynamic HTML-based dashboards is easier or file formats like “fst” are more enhanced within R. Given that R is not picky about spacing and indentation, it is an excellent language for the novice programming. As you scale your learning in analytics and coding, you will likely want to add to your language toolkit.
Exercises
1 How is an IDE different than a coding language?
2 Describe the difference between a vector and a data frame or matrix?What is the difference between a data frame and matrix?
3 Construct a vector called `position` where the values are:“Center,” “Forward,” “Guard,” “Forward,” “Forward,” and “Guard.”Change the object type from character as it was constructed into a factor.Tabulate the `position` factor object using `table` in a new object called `tallyPosition`.Use a new function to quickly create a bar plot of the results. To do so, apply `barplot` on the ` tallyPosition` object.
4 Load ` library(RCurl) ` then create an object called “bostonStats” by loading the file here: https://raw.githubusercontent.com/kwartler/Practical_Sports_Analytics/main/C1_Data/2019-2020%20Boston%20Player%20Stats.csvHow many rows does this data frame have?How many columns does this data frame have?Examine the last 4 rows of the data programmatically? What player is listed as the fourth from the bottom?Using either indexing or column name, get summary statistics for the `GP_games_played` column. What is the third quartile of this statistic?
5 Load ` library(ggplot2) ` then create a quick plot of ` STEALS_PER_GAME` and ` TURNOVERS_PER_GAME`. Does there appear to be a relationship to the syle of play for strong defense and turnovers?
6 Load `library(tidyr)`, then create a heatmap of the Boston team data using ` REBOUNDS_PER_GAME`, ` ASSISTS_PER_GAME`, ` STEALS_PER_GAME`, and `BLOCKS_PER_GAME` by ` ï.PLAYER`Create a small data frame renaming the player column.Pivot the data frame.Create a `ggplot` visual with the pivoted data where` aes(x = stat, y = player, fill = value)`The chart type is `geom_tile()`The color intensity scales from “lightgreen” to “darkred”The x-axis label “Basketball Statistics”
Конец ознакомительного фрагмента.
Текст предоставлен ООО «ЛитРес».
Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.
Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.