fnWeight: A Flexibily Function to Calculate Proportions

Description Usage Arguments Value Examples

Description

This function will take in a data set (of class data.table) and will calculate shares by a specified volume, for a main variable (default is ToolName), and optional groupings.

Usage

1
fnWeight(dat, resp = NULL, term = NULL, calc = NULL)

Arguments

dat

A dataset with a specified structure (details coming soon...)

resp

The variable we would like to calculate a share for

term

Any groupings we'd like to apply in our calculation

calc

An r expression that will determine the numerator of our share calculation

Value

Returns a table with shares

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
##
## Basic use of FnMix
##
library(data.table)
library(easydata)

## Load example dataset:
##  - Then change all potential numeric columns, to numeric
##    classes (this does it safely, quickly, and by reference)
#
data("fiberCountyDem")
NumMorph(fiberCountyDem)

## Calculate each state's share of total US population,
## by each year in our data
#
result <- fnWeight(fiberCountyDem, "State", "Year", sum(Population))
head(result)

bfatemi/dvAnalytics documentation built on May 12, 2019, 7:26 p.m.