Biogen-Inc / IDEAFilter

An R Shiny Filtering module. Demo the shiny module at: https://bit.ly/demo_IDEAFilter
https://biogen-inc.github.io/IDEAFilter/
Other
12 stars 2 forks source link

deprecated usage from shiny_data_filter.R #15

Open jhk0530 opened 1 year ago

jhk0530 commented 1 year ago

Hi. thanks for nice code. 😎

I'm building customized package using tidyCDISC (that utilize this IDEAFilter)

스크린샷 2023-07-11 오후 11 50 10

when I run that app in local. it returns above warning message.

and eventually... I found it's from this IDEAFilter's code. (not tidyCDISC) 😮

below is from shiny_data_filter.R line 247 ~ 253

reactive({
    filter_log("recalculating filtered data", verbose = verbose)
    structure(
      d <- filter_returns[[utils::tail(filters(), 1)]]$data(),
      code = code(),
      class = c("shinyDataFilter_df", class(d)))
  })

warning message shows that

structure(NULL, *) is deprecated... so use structure(list(), *) instead.

which means, if d is NULL, it will use deprecated code, and produce this warning message.

so I changed code as below (only related to d) to replace NULL to list() using ifelse

reactive({
    filter_log("recalculating filtered data", verbose = verbose)
    structure(
      d <- ifelse(
        is.null(filter_returns[[utils::tail(filters(), 1)]]$data()),  # previous d
        list(), # if d is NULL use list()
        filter_returns[[utils::tail(filters(), 1)]]$data() # d is not null, so use previous d
      ),
      code = code(),
      class = c("shinyDataFilter_df", class(d)))
  })

and I checked message doesn't show anymore.

스크린샷 2023-07-12 오전 12 23 50

I made PR with this.

please check this and let me know if you have any issues or questions.

Thanks in advance

Kim