add_row_to_ternary_df | R Documentation |
data.frame
Use this function on a data.frame
object (with values only
in the 3-element set {-1,0,1} ideally - specifying either a positive,
negative or none/absent condition/state/result about something) and add an
extra first or last row vector with zero values, where 1
and -1 will be filled when the column names of the given
data.frame
match the values in the values.pos or
values.neg vector parameters respectively.
add_row_to_ternary_df(
df,
values.pos,
values.neg,
pos = "first",
row.name = NULL
)
df |
a |
values.pos |
a character vector whose elements are indicators of a
positive state/condition and will be assigned a value of 1.
These elements must be a subset of the column names of the given |
values.neg |
a character vector whose elements are indicators of a
negative state/condition and will be assigned a value of -1.
If empty, no values equal to -1 will be added to the new row.
These elements must be a subset of the column names of the given |
pos |
string. The position where we should put the new row that will be generated. Two possible values: "first" (default) or "last". |
row.name |
string. The name of the new row that we will added. Default value: NULL. |
the df
with one extra row, having elements from the {-1,0,1}
set depending on values of values.pos
and values.neg
vectors.
df = data.frame(c(0,-1,0), c(0,1,-1), c(1,0,0))
colnames(df) = c("A","B","C")
df.new = add_row_to_ternary_df(df, values.pos = c("A"), values.neg = c("C"), row.name = "Hello!")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.