listcol_pivot | R Documentation |
Some outputs of the get_
and parse_
functions contain list-columns (e.g. the labels column in the issues dataframe).
This is an efficient way to represent the provided information, but may make certain information seem slightly inaccessible. This
function allows users to "pivot" these list columns and instead create a seperate indicator variable to represent the presence
or absence of matches within the list column.
listcol_pivot(
data,
col_name,
regex = ".",
transform_fx = identity,
delete_orig = FALSE
)
data |
Dataframe containing a list column (e.g. an issues dataframe) |
col_name |
Character string containing column name of list column (e.g. |
regex |
Character string of regular expression to identify list items of interest (e.g. |
transform_fx |
Function to transform label name before converting to column (e.g. |
delete_orig |
Logical denoting whether or not to delete original list column provided by |
For example, if a repository tags issues with "priority:high", "priority:medium", and "priority:low" along with other labels,
this function could be used to create separate "high", "medium", and "low" columns to denote different issue severities. This
could be done with listcol_pivot(data, "labels_name", "^priority:", function(x) sub("^priority:", ""))
Dataframe additional logical columns denoting absence / presence of specified list-column elements
## Not run:
issues <- get_issues(repo)
issues_df <- parse_issues(issues)
listcol_pivot(issues_df,
col_name = "labels_name",
regex = "^priority:",
transform_fx = function(x) paste0("label_",x),
delete_orig = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.