mkt_share_from_sales: Create Market Shares from Quantity Sold

Description Usage Arguments Value Examples

View source: R/create_shares.R

Description

Create Market Shares from Quantity Sold

Usage

1
mkt_share_from_sales(df, quantity, population, frac_pop = 1)

Arguments

df

Dataframe to work with

quantity

Variable containing number of goods sold, as a character string.

population

Variable containing number of number of individuals in the market, as a string.

frac_pop

Fraction of population to use when obtaining market shares, between 0 and 1.

Value

A dataframe with the variable mkt_share added as a column.

Examples

1
2
3
4
5
6
7
8
9
# Relevant market is entire population
new_df <- mkt_share_from_sales(eurocars,
                               quantity   = 'qty_sold',
                               population = 'population')
# Relevant market is 1/2 the entire population
new_df <- mkt_share_from_sales(eurocars,
                               quantity   = 'qty_sold',
                               population = 'population',
                               frac_pop   =  0.5)

lachlandeer/demandr documentation built on May 21, 2019, 12:04 p.m.