Description Usage Arguments Details Examples
calc
calculates standard estimates of TV viewing, called facts
in Instar Analytics. The formulae are documented in Instar Analytics and the
Mediapulse documentation "Gold Standards". calc
aimes to yeld exactly
the same results as Instar Analytics. calc.uni
calculates sample
and universe
, calc.share
calculates the share.
1 2 3 4 5 6 |
dt |
A data.table, a left join of |
by |
A character vector, specifying the groups by which the facts will be calculated. Default is day. Fact are always calculated by day, plus optionally more grouping variables. Make sure that sample and universe were calculated by the very same variables (targets). |
period |
A character vector, specifying the name of the column which
represents the period. By default this is 'day'. The Period is needed to
calculated the Rating ( |
unit |
One of |
na.to.0 |
|
x |
A data.table, usually the object |
target |
A character vector, specifying the variables by which sample
and universe will be calculated. By default |
obs |
The level observation, either 'ind' or 'hh'. Is the column
|
calc.uni
calculates sample
and universe
in the dem
file. To calculate facts, first sample
and universe
have to be
calculated and added as columns to dem
, see details.
calc.share
calculates the share, typically between channels. Share
by definition is calculated based on the fact rtgP
Rating in Percent.
By default the following facts are returned:
sample,universe,n,dur,rchT,rchP,rtgT,rtgP,share
. Attention! share
usually is incorrect and has to be calculated separately.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | library(tv)
setup('2018-01-01', dem.var = 'sg', import = TRUE)
dem[] # By default sample and universe are already calculated (added as columns),
# targets are all the variables specified in setup(..., dem.var = ).
# This is not always inteded, make sure to have the correct targets
# before calculating facts.
# calculate sample and universe
setup('2018-01-01', 3, dem.var = c('sg','hhsize'), dem.uni = FALSE, import = TRUE)
dem[] # setup(dem.uni = FALSE) will suppress the calculation of sample and universe.
calc.uni(dem, target = 'sg') # calculate sample and universe with target 'sg'
# sample and universe are always calculated by day.
# with sample and target by 'sg' we can now calculate facts by 'sg'.
res <- calc(view[dem, on = c('day','pin')], by = c('day','sg'))
res[]
# If we want facts by sg and hhsize we first have to calculate the correct sample and universe:
calc.uni(dem, target = c('sg','hhsize')) # overwriting the columns sample and universe
res <- calc(view[dem, on = c('day','pin')], by = c('day','sg','hhsize'))
res[]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.