Create Market Shares from Quantity Sold
mkt_share_from_sales(df, quantity, population, frac_pop = 1)
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. |
A dataframe with the variable mkt_share
added as a column.
# 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)