-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
revdepReverse dependenciesReverse dependencies
Milestone
Description
revdep panelaggregation has the following new error running examples with data.table from github master installed:
* checking examples ... ERROR
Running examples in 'panelaggregation-Ex.R' failed
The error most likely occurred in:
> ### Name: computeShares
> ### Title: Compute Weighted Shares By Group
> ### Aliases: computeShares
>
> ### ** Examples
>
> # TODO: add new weight columns to BTS demo
> # load library and dataset
> library(panelaggregation)
> data(btsdemo)
> head(btsdemo)
uid year period weight question_1 question_2 question_3 question_4
<int> <int> <int> <num> <fctr> <fctr> <fctr> <fctr>
1: 2 1997 3 1 2 2 2 1
2: 2 1997 1 1 1 2 3 1
3: 2 1995 4 1 2 1 3 1
4: 2 1998 4 1 3 2 3 3
5: 2 2001 3 1 1 3 2 2
6: 2 1999 4 1 2 3 1 2
question_5 group altGroup sClass date_qtrly
<fctr> <fctr> <fctr> <fctr> <char>
1: 2 A a S 1997-07-01
2: 2 A a S 1997-01-01
3: 3 A a S 1995-10-01
4: 3 A a S 1998-10-01
5: 3 A a S 2001-07-01
6: 1 A a S 1999-10-01
> # adapt the levels to positive, equal and negative
> # in order to suit the naming defaults. other levels work too,
> # but you'd need to specify multipliers in computeBalance then
> levels(btsdemo$question_1) <- c("pos","eq","neg")
>
> # compute the weighted shares and display store in wide format
> # to get a basis for further steps
> level1 <- computeShares(btsdemo,"question_1","weight",
+ by = c("date_qtrly","group", "altGroup", "sClass"))
>
> # compute balance, don't have to do much here, because
> # (pos, eq, neg) is the default for the possible answers
> level1_wbalance <- computeBalance(level1)
>
> # Select a particular grouping combination and a timeseries that
> # should be extracted from the level 1 aggregation.
> ts1 <- extractTimeSeries(level1_wbalance,
+ "date_qtrly",
+ list(group = "C", altGroup = "a", sClass = "S"),
+ freq = 4,
+ item = "balance",
+ variable = "question_1")
> ts1
Qtr1 Qtr2 Qtr3 Qtr4
1995 -0.0545830462 0.0288077188 -0.3718939812 0.0199862164
1996 -0.5014472777 0.1983459683 0.3882531366 -0.3687112336
1997 -0.1538673652 0.1518952447 -0.2290833908 -0.0008270159
1998 -0.3101641153 0.0000000000 0.1481736733 -0.3601654032
1999 0.1447277739 0.1403170227 -0.2453818583 -0.0150241213
2000 -0.0880771881 0.0024810476 -0.1689869056 0.1634734666
2001 -0.1317711923 0.4347346657 -0.3554789800
> # Plot a standard R ts using the plot method for ts
> plot(ts1, main = attributes(ts1)$ts_key)
>
> # Add weight column to the aggregated results
> # In order to join the tables, we need to know what weight to assign to each row.
> # This is done by having via a common key, for example c('group', 'altGroup').
> # In this example we would assign a different weight for each
> # c('group', 'altGroup') combination (e.g. c('A', 'a')).
> btsweight1 <- btsdemo[, list(weight = sum(weight)), by = 'group']
> btsagg1 <- joinDataTables(level1_wbalance, btsweight1, 'group')
>
> # Compute second level aggregation, this time on fewer columns and using a different set of weights.
> level2_balance <- computeWeightedMeans(btsagg1, c('item_pos', 'item_eq', 'item_neg', 'balance'),
+ 'weight', c("date_qtrly","group", "sClass"))
Error in gweighted.mean(item_pos, weight = eval(as.name(weight)), na.rm = TRUE) :
unused argument (weight = eval(as.name(weight)))
Calls: computeWeightedMeans -> [ -> [.data.table -> gforce
Execution halted
git bisect says this error started happening after merging #5246
@ben-schwen could you please have a look since you were the author of that PR?
Metadata
Metadata
Assignees
Labels
revdepReverse dependenciesReverse dependencies