formatDf: Format dataframe

Description Usage Arguments Details Value

View source: R/format_data.R

Description

formatDf returns a dataframe formatted to visualize aggregated column stats

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
formatDf(
  dt,
  match,
  rowStat,
  statTeam,
  nStats,
  dStats,
  statName,
  xStat,
  valType
)

Arguments

dt

A dataframe of stats, eg. a Sportscode matrix output.

match

(optional) A string. Indicates the game of interest.

rowStat

(optional) A string. Indicates the specific row of interest.

statTeam

(optional*) A string. Indicates the team for which the user wants to pull the stats. - *if the user does not pass in a rowStat, they must pass in a statTeam

nStats

A vector of strings. Indicate the columns used to calculate the aggregated value, or the numerator of a ratio when dStats are also passed in.

dStats

(optional) A vector of strings. Indicate the columns used to calculate the denominator of a ratio.

statName

A string. Indicates the formatted stat name for the plot.

xStat

(optional) A string. Adds a stat column to the dataframe; for plots that use the stat variable along the x axis.

valType

(optional) A string. Indicates how to calculate the stat value and set the stat label for the plot

Details

This function returns a formatted dataframe for visualizing data when the column stats are aggregated together (eg. summed, used to calculate a ratio, etc.).

Value

If all parameters are valid for the input dataframe, then the output will be a formatted dataframe.


ludisanalytics/ludisviz documentation built on Jan. 30, 2021, 12:46 a.m.