choose_value: Choose a value from a dataframe

View source: R/choose_value.R

choose_valueR Documentation

Choose a value from a dataframe

Description

Returns the value of a variable in a dataframe, for a given value of another variable in the dataframe.

Usage

choose_value(df, var_name, additional_name, additional_value)

Arguments

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.

Examples


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



moj-analytical-services/mojrap documentation built on July 30, 2023, 4:43 p.m.