choonghyunryu / dlookr

Tools for Data Diagnosis, Exploration, Transformation
https://choonghyunryu.github.io/dlookr/
208 stars 35 forks source link

Error in UseMethod("select") #84

Closed KatlehoJordan closed 1 year ago

KatlehoJordan commented 1 year ago

Using eda_web_report gave strange unexpected error.

library("dplyr")

ds <- survival::colon

ds_complete <- ds

ds %<>%
    filter((status == 0) & (etype == 2)) %>%
    select(-status, -etype, -study)

# Strangely, fail to use %<>% pipe here...
ds <- ds %>%
    filter(!is.na(nodes) & !is.na(differ))

ds <- ds %>%
    select(-node4)

ds %>%
    dlookr::eda_web_report(
        target = time,
        output_file = "Targeted EDA report",
        output_dir = "."
    )

Error message from final command:

Error in UseMethod("select") : 
 no applicable method for 'select' applied to an object of class "c('relate', 'lm')"
choonghyunryu commented 1 year ago

@KatlehoJordan,

I couldn't reproduce the error in my environment. Performed normally.

I want to know your R environment. Please tell us the result of sessionInfo() and the version of dlookr.

KatlehoJordan commented 1 year ago

@KatlehoJordan,

I couldn't reproduce the error in my environment. Performed normally.

I want to know your R environment. Please tell us the result of sessionInfo() and the version of dlookr.

Sorry, this was from a side project so it does not get much of my attention. I will try to replicate next week and provide you my envirionment details. If I cannot replicate, I will happily close the issue. Please just give me a week to follow up, :smile:.

KatlehoJordan commented 1 year ago
> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux bookworm/sid

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] dlookr_0.6.0 dplyr_1.0.10

loaded via a namespace (and not attached):
 [1] httr_1.4.4        sass_0.4.2        tidyr_1.2.1       jsonlite_1.8.3   
 [5] viridisLite_0.4.1 splines_4.2.1     showtext_0.9-5    bslib_0.4.1      
 [9] Formula_1.2-4     shiny_1.7.3       highr_0.9         showtextdb_3.0   
[13] yaml_2.3.6        gdtools_0.2.4     Rttf2pt1_1.3.11   pillar_1.8.1     
[17] lattice_0.20-45   glue_1.6.2        extrafontdb_1.0   digest_0.6.30    
[21] promises_1.2.0.1  rvest_1.0.3       colorspace_2.0-3  htmltools_0.5.3  
[25] httpuv_1.6.6      Matrix_1.5-1      reactR_0.4.4      hrbrthemes_0.8.0 
[29] pkgconfig_2.0.3   sysfonts_0.8.8    purrr_0.3.5       xtable_1.8-4     
[33] mvtnorm_1.1-3     scales_1.2.1      webshot_0.5.4     fontawesome_0.4.0
[37] svglite_2.1.0     later_1.3.0       tibble_3.1.8      mgcv_1.8-40      
[41] farver_2.1.1      generics_0.1.3    ggplot2_3.3.6     ellipsis_0.3.2   
[45] cachem_1.0.6      withr_2.5.0       cli_3.4.1         survival_3.3-1   
[49] magrittr_2.0.3    mime_0.12         pagedown_0.19     evaluate_0.17    
[53] reactable_0.3.0   fansi_1.0.3       nlme_3.1-158      MASS_7.3-57      
[57] xml2_1.3.3        tools_4.2.1       lifecycle_1.0.3   stringr_1.4.1    
[61] munsell_0.5.0     kableExtra_1.3.4  compiler_4.2.1    jquerylib_0.1.4  
[65] inum_1.0-4        systemfonts_1.0.4 rlang_1.0.6       grid_4.2.1       
[69] rstudioapi_0.14   htmlwidgets_1.5.4 base64enc_0.1-3   labeling_0.4.2   
[73] rmarkdown_2.17    partykit_1.2-16   gtable_0.3.1      curl_4.3.3       
[77] R6_2.5.1          gridExtra_2.3     knitr_1.40        fastmap_1.1.0    
[81] extrafont_0.18    utf8_1.2.2        libcoin_1.0-9     stringi_1.7.8    
[85] Rcpp_1.0.9        vctrs_0.5.0       rpart_4.1.16      tidyselect_1.2.0 
[89] xfun_0.34        
> 
choonghyunryu commented 1 year ago

@KatlehoJordan,

Thanks for the information. After installing the development version with the following command, try running it again.

devtools::install_github("choonghyunryu/dlookr")

Thanks!

KatlehoJordan commented 1 year ago

I am running this in a dev container to isolate it from my system-wide environment. Devtools installation is usually a pain in the butt to get up and running due to so many dependencies. I tried simply installing devtools into the dev container, and that's exactly what happened... It did not install correctly due to missing dependencies.

Since this is a side project, I am not going to put more time into it.

If you would still like to try to solve this, then here is the Dockerfile I used:

FROM r-base:4.2.1
COPY . .
RUN apt-get update && \
    apt-get install -y \
        # Required for installing languageserver R package
        libxml2-dev \
        # Required for installing dlookr R package
        curl \
        libcairo2-dev \
        libcurl4-openssl-dev \
        libfontconfig1-dev \
        libfreetype6-dev \
        libssl-dev \
        pandoc \
        # Required for installing survminer R package
        cmake \
        && \
    # Install R packages
    Rscript dependencies.R
CMD [""]

and here is dependencies.R:

# Detect cores to use for parallel installations
cores_to_use <- min(parallel::detectCores() - 2, 1)

# Enables installation of specific versions of other packages
install.packages("remotes", Ncpus = cores_to_use)

packages <- c(

    # Enables VS Code extension features but takes a long time to install
    "languageserver" = "0.3.14",

    # Enables piping and dplyr data-manipulation verbs
    "dplyr" = "1.0.10",

    # Enables rapid exploratory data analysis, take a long time to install
    "dlookr" = "0.6.0",
    # Enables use of dlookr::eda_report function
    "prettydoc" = "0.4.1",
    "Hmisc" = "4.7.1",
    # Enables plotting survival analysis models
    "survminer" = "0.4.9",
    "httpgd" = "1.3.0"
)

for (pkg in names(packages)) {
    remotes::install_version(pkg, packages[pkg], Ncpus = cores_to_use)
}

and here is the script that is having the problems:

library("dplyr")

ds <- survival::colon

ds_complete <- ds

ds %<>%
    filter((status == 0) & (etype == 2)) %>%
    select(-status, -etype, -study)

# Strangely, fail to use %<>% pipe here...
ds <- ds %>%
    filter(!is.na(nodes) & !is.na(differ))

ds <- ds %>%
    select(-node4)

ds %>%
    dlookr::eda_web_report(
        target = time,
        output_file = "Targeted EDA report",
        output_dir = "."
    )

# As instructed on github, use dev version of library
devtools::install_github("choonghyunryu/dlookr")

# Error, no package called dev tools
install.packages("devtools")

# Error, failed to install due to missing dependencies
# Decided not to pursue this further

Feel free to close this if you like, even though the problem was not resolved.

choonghyunryu commented 1 year ago

@KatlehoJordan,

dlookr 0.6.1 registered with CRAN. You can now install with install.packages("dlookr").