{"id":1022,"date":"2019-11-18T09:58:07","date_gmt":"2019-11-18T09:58:07","guid":{"rendered":"https:\/\/bodai.unibs.it\/bdsports\/?page_id=1022"},"modified":"2022-04-28T12:58:37","modified_gmt":"2022-04-28T10:58:37","slug":"basketballanalyzer-faq","status":"publish","type":"page","link":"https:\/\/bodai.unibs.it\/bdsports\/basketballanalyzer\/basketballanalyzer-faq\/","title":{"rendered":"BasketballAnalyzeR &#8211; FAQ"},"content":{"rendered":"<h1>BasketballAnalyzeR &#8211; FAQ<\/h1>\n<hr \/>\n<h3>INSTALLING THE PACKAGE<\/h3>\n<ul>\n<li>\n<h5><b>General suggestion in case of installation problems<\/b><b>.<\/b> <code><\/code><\/h5>\n<\/li>\n<\/ul>\n<p>Sometimes it is recommended to run R \u201cas administrator\u201d.<\/p>\n<ul>\n<li>\n<h5><b>When installing <\/b><code>BaskeballAnalizeR<\/code>,<b> some or all the dependent packages are not automatically installed.<\/b> <code><\/code><\/h5>\n<\/li>\n<\/ul>\n<p>Close all R sessions and open a new R session, then type:<\/p>\n<p><code>reqpacks&lt;- c('ggplot2', 'hexbin', 'plyr', 'dplyr', 'tidyr', 'rlang', 'magrittr', 'ggrepel',<br \/>\n'gridExtra', 'scales', 'MASS', 'directlabels', 'corrplot', 'ggplotify', 'network',<br \/>\n'sna', 'dendextend', 'circlize', 'PBSmapping', 'sp', 'operators', 'stringr', 'GGally',<br \/>\n'statnet', 'common', 'ggnetwork', 'readr')<\/code><\/p>\n<p><code>install.packages(reqpacks)<\/code><\/p>\n<p>&nbsp;<\/p>\n<h3>REPLICATING THE EXAMPLES IN THE BOOK &#8220;BASKETBALL DATA SCIENCE&#8221;<\/h3>\n<ul>\n<li>\n<h5>The top-left panel of Figure 2.1 and the top panel of Figure 2.2 have different values on the axes.<\/h5>\n<\/li>\n<\/ul>\n<p>There was a mistake in the function <code>fourfactors<\/code>. 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 <a href=\"https:\/\/bodai.unibs.it\/bdsports\/basketballanalyzer\/errata-corrige\/\">ERRATA CORRIGE<\/a> of the book &#8220;Basketball Data Science&#8221;).<\/p>\n<ul>\n<li>\n<h5><strong>Error in grid.Call \u2026 Viewport has zero dimension(s)<\/strong>.<\/h5>\n<\/li>\n<\/ul>\n<p>Under certain circumstances, some plotting commands of <code>BaskeballAnalizeR<\/code> can throw the following error:<br \/>\n<code>Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto),\u00a0 :<br \/>\nViewport has zero dimension(s)<\/code><\/p>\n<p>This error is not easily reproducible with <code>BaskeballAnalizeR<\/code>.<\/p>\n<p>In RStudio, it can be generated by setting a small width of the plot area and running the following example:<br \/>\n<code>library(BasketballAnalyzeR)<br \/>\ntm &lt;- c(\"BOS\",\"CLE\",\"GSW\",\"HOU\")<br \/>\nselTeams &lt;- which(Tadd$team %in% tm)<br \/>\nFF.sel &lt;- fourfactors(Tbox[selTeams,], Obox[selTeams,])<br \/>\nplot(FF.sel)<\/code><\/p>\n<p>The problem seems connected to the use of the R package <code>ggrepel<\/code> and a too large legend. See this <a href=\"https:\/\/github.com\/slowkow\/ggrepel\/issues\/113\">link<\/a> for details.<\/p>\n<p>A possible solution is to reduce the length of the legend labels or to split labels over multiple lines using the newline character <code>\\n<\/code>. See this example related to the analysis presented in Section 2.2.1:<br \/>\n<code>tm &lt;- c(\"BOS\",\"CLE\",\"GSW\",\"HOU\")<br \/>\nselTeams &lt;- which(Tadd$team %in% tm)<br \/>\nFF.sel &lt;- fourfactors(Tbox[selTeams,], Obox[selTeams,])<br \/>\nFF.sel$Team &lt;- c(\"Boston Celtics\", \"Cleveland Cavaliers\",\"Golden State\\nWarriors\", \"Houston Rockets\")<br \/>\nplot(FF.sel)<\/code><\/p>\n<p>Otherwise, try to adjust the width of the plot area.<\/p>\n<p><em>Thanks to Christopher Riccio who reported this problem.<\/em><\/p>\n<ul>\n<li>\n<h5>Section 3.4 of the book &#8220;Basketball Data Science&#8221;: although I have set the correct seed (command <code>set.seed(7)<\/code> and\/or <code>set.seed(1)<\/code>), I obtain a different outcome with respect to that reported on the book.<\/h5>\n<\/li>\n<\/ul>\n<p>It used to be the case that <code>set.seed()<\/code> would give the same results across R versions, but that&#8217;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 &gt;= 3.6.0, you need to type <code>RNGkind(sample.kind = \"Rounding\")<\/code> 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 <code>BaskeballAnalizeR<\/code> is uploaded.<\/p>\n<ul>\n<li>\n<h5>Section 4.2.1 of the book &#8220;Basketball Data Science&#8221;: although I have set the correct seed (command <code>set.seed(29)<\/code>), I obtain a different outcome with respect to that reported on the book.<\/h5>\n<\/li>\n<\/ul>\n<p>It used to be the case that <code>set.seed()<\/code> would give the same results across R versions, but that&#8217;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 &gt;= 3.6.0, you need to type <code>RNGkind(sample.kind = \"Rounding\")<\/code> 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 <code>BaskeballAnalizeR<\/code> is uploaded.<\/p>\n<ul>\n<li>\n<h5>Section 4.2.2 of the book &#8220;Basketball Data Science&#8221;: although I have set the correct seed (command <code>set.seed(1)<\/code>), I obtain a different outcome with respect to that reported on the book.<\/h5>\n<\/li>\n<\/ul>\n<p>It used to be the case that <code>set.seed()<\/code> would give the same results across R versions, but that&#8217;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 &gt;= 3.6.0, you need to type <code>RNGkind(sample.kind = \"Rounding\")<\/code> 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 <code>BaskeballAnalizeR<\/code> is uploaded.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>BasketballAnalyzeR &#8211; FAQ INSTALLING THE PACKAGE General suggestion in case of installation problems. Sometimes it is recommended to run R \u201cas administrator\u201d. When installing BaskeballAnalizeR, some or all the dependent packages are not automatically installed. Close all R sessions and open a new R session, then type: reqpacks&lt;- c(&#8216;ggplot2&#8217;, &#8216;hexbin&#8217;, &#8216;plyr&#8217;, &#8216;dplyr&#8217;, &#8216;tidyr&#8217;, &#8216;rlang&#8217;, &#8216;magrittr&#8217;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":421,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"class_list":["post-1022","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/bodai.unibs.it\/bdsports\/wp-json\/wp\/v2\/pages\/1022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bodai.unibs.it\/bdsports\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bodai.unibs.it\/bdsports\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bodai.unibs.it\/bdsports\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bodai.unibs.it\/bdsports\/wp-json\/wp\/v2\/comments?post=1022"}],"version-history":[{"count":6,"href":"https:\/\/bodai.unibs.it\/bdsports\/wp-json\/wp\/v2\/pages\/1022\/revisions"}],"predecessor-version":[{"id":2005,"href":"https:\/\/bodai.unibs.it\/bdsports\/wp-json\/wp\/v2\/pages\/1022\/revisions\/2005"}],"up":[{"embeddable":true,"href":"https:\/\/bodai.unibs.it\/bdsports\/wp-json\/wp\/v2\/pages\/421"}],"wp:attachment":[{"href":"https:\/\/bodai.unibs.it\/bdsports\/wp-json\/wp\/v2\/media?parent=1022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}