choose_value | R Documentation |
Returns the value of a variable in a dataframe, for a given value of another variable in the dataframe.
choose_value(df, var_name, additional_name, additional_value)
df |
A dataframe. |
var_name |
Name of the variable we want to extract a value from, as a string. |
additional_name |
The name of a column used to filter the dataframe on, as a string. |
additional_value |
A value in the column to filter the dataframe for. |
df <- data.frame("yrqtr" = c("2020 Q1", "2020 Q2", "2020 Q3", "2020 Q4"),
"receipts" = seq(10, 40, 10)
)
choose_value(df, "receipts", "yrqtr", "2020 Q1") # returns 10
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.