{"id":1965,"date":"2021-02-14T22:57:48","date_gmt":"2021-02-14T22:57:48","guid":{"rendered":"http:\/\/optimumsportsperformance.com\/blog\/?p=1965"},"modified":"2021-02-15T14:26:52","modified_gmt":"2021-02-15T14:26:52","slug":"tidyx-49-rowwise-simulation-of-mlb-batting-average-gt-table-sparklines","status":"publish","type":"post","link":"https:\/\/optimumsportsperformance.com\/blog\/tidyx-49-rowwise-simulation-of-mlb-batting-average-gt-table-sparklines\/","title":{"rendered":"TidyX 49: rowwise simulation of MLB Batting Average, {gt} table &#038; sparklines"},"content":{"rendered":"<p>This week, <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/twitter.com\/ellis_hughes\">Ellis Hughes<\/a><\/span><\/strong> and I continue our work on simulation methods in R by introducing the <strong>rowwise<\/strong> function from the <strong>{tidyverse}<\/strong> package. We use this function to do simulations of batting average at the player level. Basically, the function allows us to easily apply a simulation to each row, which represents one player&#8217;s seasons, of the data set. We then build our results into a <strong>{gt}<\/strong> table and use <strong>sparklines<\/strong>.<\/p>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2021\/02\/Screen-Shot-2021-02-14-at-2.56.57-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1966\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2021\/02\/Screen-Shot-2021-02-14-at-2.56.57-PM-1024x962.png\" alt=\"\" width=\"625\" height=\"587\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2021\/02\/Screen-Shot-2021-02-14-at-2.56.57-PM-1024x962.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2021\/02\/Screen-Shot-2021-02-14-at-2.56.57-PM-300x282.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2021\/02\/Screen-Shot-2021-02-14-at-2.56.57-PM-768x721.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2021\/02\/Screen-Shot-2021-02-14-at-2.56.57-PM-624x586.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2021\/02\/Screen-Shot-2021-02-14-at-2.56.57-PM.png 1410w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>To watch our screen cast, <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/www.youtube.com\/watch?v=aVrS4ZVpIOk&amp;feature=youtu.be\">CLICK HERE<\/a><\/span><\/strong>.<\/p>\n<p>To access our code, <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/github.com\/thebioengineer\/TidyX\/tree\/master\/TidyTuesday_Explained\/049-MLB_Batting_Simulations\">CLICK HERE<\/a><\/span><\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week, Ellis Hughes and I continue our work on simulation methods in R by introducing the rowwise function from the {tidyverse} package. We use this function to do simulations of batting average at the player level. Basically, the function allows us to easily apply a simulation to each row, which represents one player&#8217;s seasons, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44],"tags":[],"class_list":["post-1965","post","type-post","status-publish","format-standard","hentry","category-tidyx-screen-cast"],"_links":{"self":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/1965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/comments?post=1965"}],"version-history":[{"count":2,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/1965\/revisions"}],"predecessor-version":[{"id":1968,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/1965\/revisions\/1968"}],"wp:attachment":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/media?parent=1965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/categories?post=1965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/tags?post=1965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}