insongkim / PanelMatch

118 stars 36 forks source link

Throw tibble error #117

Closed bengoehring closed 1 year ago

bengoehring commented 1 year ago

Greetings.

DisplayTreatment() fails if the data is a tibble rather than a dataframe (see below). This is because of the different indexing behavior of tibbles compared to dataframes. Given the popularity of the tidyverse, it might be worthwhile to add an informative error message if someone passes a tibble rather than a dataframe.

library(PanelMatch)
DisplayTreatment(unit.id = "wbcode2",
                 time.id = "year", 
                 legend.position = "none",
                 xlab = "year", 
                 ylab = "Country Code",
                 treatment = "dem", 
                 data = dem)

dem_tibble <- as_tibble(dem)

DisplayTreatment(unit.id = "wbcode2",
                 time.id = "year", 
                 legend.position = "none",
                 xlab = "year", 
                 ylab = "Country Code",
                 treatment = "dem", 
                 data = dem_tibble)
adamrauh commented 1 year ago

Thanks for the catch! I believe we should have a more helpful error now per 059e5a1ade42397d55af3e90e31be7d71251f5bc