Sometimes it is recommended to run R “as administrator”.
BaskeballAnalizeR
, some or all the dependent packages are not automatically installed.
Close all R sessions and open a new R session, then type:
reqpacks<- c('ggplot2', 'hexbin', 'plyr', 'dplyr', 'tidyr', 'rlang', 'magrittr', 'ggrepel',
'gridExtra', 'scales', 'MASS', 'directlabels', 'corrplot', 'ggplotify', 'network',
'sna', 'dendextend', 'circlize', 'PBSmapping', 'sp', 'operators', 'stringr', 'GGally',
'statnet', 'common', 'ggnetwork', 'readr')
install.packages(reqpacks)
There was a mistake in the function fourfactors
. The corrected version is now online, so you are probably obtaining the right graphs, where the numbers involved are in the order of magnitude of 2 (see the ERRATA CORRIGE of the book “Basketball Data Science”).
Under certain circumstances, some plotting commands of BaskeballAnalizeR
can throw the following error:
Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto), :
Viewport has zero dimension(s)
This error is not easily reproducible with BaskeballAnalizeR
.
In RStudio, it can be generated by setting a small width of the plot area and running the following example:
library(BasketballAnalyzeR)
tm <- c("BOS","CLE","GSW","HOU")
selTeams <- which(Tadd$team %in% tm)
FF.sel <- fourfactors(Tbox[selTeams,], Obox[selTeams,])
plot(FF.sel)
The problem seems connected to the use of the R package ggrepel
and a too large legend. See this link for details.
A possible solution is to reduce the length of the legend labels or to split labels over multiple lines using the newline character \n
. See this example related to the analysis presented in Section 2.2.1:
tm <- c("BOS","CLE","GSW","HOU")
selTeams <- which(Tadd$team %in% tm)
FF.sel <- fourfactors(Tbox[selTeams,], Obox[selTeams,])
FF.sel$Team <- c("Boston Celtics", "Cleveland Cavaliers","Golden State\nWarriors", "Houston Rockets")
plot(FF.sel)
Otherwise, try to adjust the width of the plot area.
Thanks to Christopher Riccio who reported this problem.
set.seed(7)
and/or set.seed(1)
), I obtain a different outcome with respect to that reported on the book.It used to be the case that set.seed()
would give the same results across R versions, but that’s no longer generally true due to to a little-announced update in R 3.6.0. So, if the version of your R machine is >= 3.6.0, you need to type RNGkind(sample.kind = "Rounding")
at the beginning of your working session. This will allow you to obtain the same outcome reported on the book. A warning message about this issue is given when the library BaskeballAnalizeR
is uploaded.
set.seed(29)
), I obtain a different outcome with respect to that reported on the book.It used to be the case that set.seed()
would give the same results across R versions, but that’s no longer generally true due to to a little-announced update in R 3.6.0. So, if the version of your R machine is >= 3.6.0, you need to type RNGkind(sample.kind = "Rounding")
at the beginning of your working session. This will allow you to obtain the same outcome reported on the book. A warning message about this issue is given when the library BaskeballAnalizeR
is uploaded.
set.seed(1)
), I obtain a different outcome with respect to that reported on the book.It used to be the case that set.seed()
would give the same results across R versions, but that’s no longer generally true due to to a little-announced update in R 3.6.0. So, if the version of your R machine is >= 3.6.0, you need to type RNGkind(sample.kind = "Rounding")
at the beginning of your working session. This will allow you to obtain the same outcome reported on the book. A warning message about this issue is given when the library BaskeballAnalizeR
is uploaded.