I wish to run a Benford analysis per group for my data.
I wish to extract the MAD.conformity
and n
per group and store the output in a data frame where there would be one row per group with 3 columns, 1st column - VendorNum
, 2nd column = n
and 3rd column = MAD.conformity
I can extract the MAD.conformity
metric but when I add extra metrics to my extract I get the following error:
Any help to get the 3 metrics into a data frame would be greatly appreciated
library(dplyr)
library(purrr)
library(benford.analysis)
data(corporate.payment)
vendor_records <- corporate.payment %>%
group_by(VendorNum) %>%
summarise(records = n()) %>%
arrange(desc(records))
top_vendors <- corporate.payment %>%
filter(VendorNum %in% c('3630','6661','2001','4984'))
result <- top_vendors %>%
split(.$VendorNum) %>%
map(~ benford(number.of.digits = 1, discrete = TRUE, sign = "positive", data = .x$Amount)) %>%
map_dfr(magrittr::extract, c("MAD.conformity"))
Error:
! Column names `MAD.conformity`, `MAD.conformity`, and `MAD.conformity` must not be duplicated.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names must be unique.
x These names are duplicated:
* "MAD.conformity" at locations 1, 2, 3, and 4.