facebookincubator / GeoLift

GeoLift is an end-to-end geo-experimental methodology based on Synthetic Control Methods used to measure the true incremental effect (Lift) of ad campaign.
https://facebookincubator.github.io/GeoLift/
MIT License
175 stars 54 forks source link

Error in GeoDataRead #128

Closed miaox018 closed 1 year ago

miaox018 commented 1 year ago

Hi,

I've just installed the package but ran into issues with GeoDataRead with the walkthrough example. Could you help to take a look? Error in dplyr::summarize(): ! Problem while computing Y = sum(Y). Caused by error in sum(): ! invalid 'type' (character) of argument Run rlang::last_error() to see where the error occurred.

Attaching SessionInfo() output here, thank you!!

R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] GeoLift_2.6.01

loaded via a namespace (and not attached): [1] augsynth_0.2.0 ggrepel_0.9.3 Rcpp_1.0.10 mvtnorm_1.1-3 lattice_0.20-45 tidyr_1.3.0 listenv_0.9.0
[8] zoo_1.8-11 assertthat_0.2.1 digest_0.6.31 foreach_1.5.2 utf8_1.2.2 parallelly_1.34.0 lfe_2.8-8
[15] R6_2.5.1 plyr_1.8.8 Boom_0.9.11 ggplot2_3.4.1 pillar_1.8.1 panelView_1.1.11 rlang_1.0.6
[22] rstudioapi_0.14 Matrix_1.5-1 stringr_1.5.0 BoomSpikeSlab_1.2.5 directlabels_2021.1.13 munsell_0.5.0 proxy_0.4-27
[29] compiler_4.2.2 pkgconfig_2.0.3 globals_0.16.2 CausalImpact_1.3.0 tidyselect_1.2.0 tibble_3.1.8 gridExtra_2.3
[36] quadprog_1.5-8 dtw_1.23-1 codetools_0.2-18 fansi_1.0.3 future_1.31.0 withr_2.5.0 dplyr_1.0.10
[43] MASS_7.3-58.1 grid_4.2.2 gsynth_1.2.1 xtable_1.8-4 gtable_0.3.1 lifecycle_1.0.3 DBI_1.1.3
[50] magrittr_2.0.3 scales_1.2.1 cli_3.4.1 stringi_1.7.12 reshape2_1.4.4 doRNG_1.8.6 doParallel_1.0.17
[57] xts_0.12.2 generics_0.1.3 vctrs_0.5.2 sandwich_3.0-2 Formula_1.2-4 iterators_1.0.14 tools_4.2.2
[64] glue_1.6.2 purrr_1.0.1 rngtools_1.5.2 MarketMatching_1.2.0 abind_1.4-5 parallel_4.2.2 colorspace_2.1-0
[71] LowRankQP_1.0.5 bsts_0.9.9

ArturoEsquerra commented 1 year ago

Hi @miaox018, thanks for sharing this issue with the community!

This issue is most often caused by non-numeric characters in the KPI variable (could be commas, currency signs, etc). I would recommend double-checking the format of your data with str(dataset). Nevertheless, we'll definitely add more user-friendly warnings to the GeoDataRead() function.

Please let us know if this works!

miaox018 commented 1 year ago

Hi, thanks for getting back so quickly. However, I don't think this is a format issue- I made sure the Y is int, and used GeoLift_PreTest as a testing file but still got the same error. When I have dplyr package loaded, I can run "data %>% dplyr::group_by(location, date) %>% dplyr::summarize(., Y = sum(Y)) %>% dplyr:::summarise.grouped_df(., Y = sum(Y))" without issue.

ArturoEsquerra commented 1 year ago

Hi again @miaox018! This is definitely an atypical behavior, as long as the KPI is numeric, the GeoDataRead() function should work. I would recommend trying to re-format this variable (maybe with something like dataset$Y <- as.numeric(dataset$Y)). Alternatively, if you could share a reproducible example, we could dig deeper into this problem