openjusticeok / ojoutils

ojoutils
https://openjusticeok.github.io/ojoutils/
GNU General Public License v3.0
0 stars 0 forks source link

Add function, change, which creates text statements about changes between two data points. #10

Open anthonyokc opened 1 month ago

anthonyokc commented 1 month ago

Basically simplify making statements like this

white_poverty_statement <- case_when(
  white_poverty_change$change > 0 ~ paste0(
    "increased by ",
    abs(white_poverty_change$change * 100),
    " percentage points to"
  ),
  white_poverty_change$change < 0 ~ paste0(
    "decreased by ",
    abs(white_poverty_change$change * 100),
    " percentage points to"
  ),
  TRUE ~ paste0(
    "remained unchanged at "
  )
brancengregory commented 1 month ago

I propose describe_change as the function name

anthonyokc commented 1 month ago

I also considered change_statement but, and this is a somewhat silly reason, but when I use it inline quarto docs like r change_statement() it doesn't autocomplete the function name so it's a lot to type lmao.