Description Usage Arguments Details Value See Also Examples
View source: R/firstapiR_util.R
The firstapiR functions GetSchedule()
, GetHybridSchedule()
, and
GetMatchResults
return a data frame in team shape, i.e., with one team
listed in every row, and six rows per match. R documentation often refers to
data frames in this format as narrow data frames. ToMatchShape
will convert these narrow data frames to a wide data frame (it's wide because
it has more columns) with all six teams listed in one row and only one row
per match.
1 |
df |
A firstapiR data frame. The data frame must inherit from the schedule, hybridSchedule, or emphmatchResults class data frames that are returned by firstapiR functions. The data frame must also be in team shape and have the shape attribute set to "team". |
ToMatchShape will only convert data frames that are in team shape, with their
shape attribute set to "team". To convert a data frame that is in alliance
shape to match shape, first use ToTeamShape()
to convert the data
frame back to team shape, and then use ToMatchShape()
to convert it to
match shape.
FirstapiR proivdes functions to reshape data frames because different shapes are useful for different purposes. For example, team shape is useful for extracting data for a single team because it's only necessary to subset the data frame on the team column. Match shape is useful for displaying schedules. Alliance shape is useful for calculating offensive power rating (OPR).
This function throws an error if df does not inherit from matchResults, schedule, or hybridSchedule, or if the data frame's shape attribute is missing or is anything other than team.
A data frame of class matchResults, schedule, or hybridSchedule (depending on the class of the df argument) in match shape, with the shape attribute set to "match".
GetMatchResults
, GetHybridSchedule
,
GetSchedule
1 2 3 | sn <- GetSession("myUserName", "key", season = 2016)
matchResults_teamshape <- GetMatchResults(sn, event = "PNCMP")
matchResults_matchshape <- ToMatchShape(matchResults_teamshape)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.