Code Monkey home page Code Monkey logo

Comments (6)

ge-li avatar ge-li commented on June 18, 2024

Hello, thanks for creating such an amazing package for summarizing simulation results. I saw this issue so I want to add a small suggestion here. It seems the print.summary.simsum() function will only print those nice tables but the summary tables are not returned. This is somewhat inconvenient for channeling the R output for other uses. I know I can extract the "tidy" long table from the summary object directly or use the tidy() function but they are not good for presentation purposes. What are your thoughts on this? Thank you very much!

from rsimsum.

ellessenne avatar ellessenne commented on June 18, 2024

Hi, thanks for your feedback!
Just to understand better your comment, would you like print.summary.simsum() to return the formatted tables that are printed to the R console?

from rsimsum.

ge-li avatar ge-li commented on June 18, 2024

Yes. I'll be more specific. Allow me to explain.

Currently the print.summary.simsum() doesn't return anything other than printing the required summary tables. Personally, I think a better design is that it returns a (list) of summary data frames, maybe the output object in your code. I want this feature because such tables are better suited for presenting the results than the tidy format summary tables if I have a methodvar. And I cannot really use R's printed data frame conveniently for other purposes, e.g., making it into kables.

  ### If methodvar, put them side by side
  if (!is.null(x$methodvar)) {
    x$summ <- .bind_methods(data = x$summ, by = x$by, methodvar = x$methodvar)
  }

  ### Split by summary statistics for printing
  x$summ[["Performance Measure"]] <- droplevels(x$summ[["Performance Measure"]])
  output <- .split_by(data = x$summ, by = "Performance Measure")

  ### Print
  for (i in seq_along(output)) {
    cat(paste0("\n", names(output)[i], ":\n"))
    output[[i]][["Performance Measure"]] <- NULL
    print(output[[i]], row.names = FALSE)
  }

from rsimsum.

ellessenne avatar ellessenne commented on June 18, 2024

Aha, now I see – something like the example below?

library(rsimsum)
s2 <- simsum(data = relhaz, estvarname = "theta", true = -0.50, se = "se", methodvar = "model", by = c("baseline", "n"))
#> 'ref' method was not specified, Cox set as the reference
a <- print(summary(s2, stats = "bias"))
#> Values are:
#>  Point Estimate (Monte Carlo Standard Error)
#> 
#> Bias in point estimate:
#>     baseline   n              Cox              Exp            RP(2)
#>  Exponential  50  0.0215 (0.0328)  0.0239 (0.0326)  0.0183 (0.0331)
#>  Exponential 250 -0.0215 (0.0149) -0.0214 (0.0151) -0.0227 (0.0149)
#>      Weibull  50 -0.0282 (0.0311)  0.1509 (0.0204) -0.0348 (0.0311)
#>      Weibull 250 -0.0120 (0.0133)  0.1482 (0.0093) -0.0139 (0.0137)
library(knitr)
#> 
#> Attaching package: 'knitr'
#> The following object is masked from 'package:rsimsum':
#> 
#>     kable
kable(a[[1]], caption = names(a)[1], align = "r")
baseline n Cox Exp RP(2)
Exponential 50 0.0215 (0.0328) 0.0239 (0.0326) 0.0183 (0.0331)
Exponential 250 -0.0215 (0.0149) -0.0214 (0.0151) -0.0227 (0.0149)
Weibull 50 -0.0282 (0.0311) 0.1509 (0.0204) -0.0348 (0.0311)
Weibull 250 -0.0120 (0.0133) 0.1482 (0.0093) -0.0139 (0.0137)

Bias in point estimate

Created on 2021-09-16 by the reprex package (v2.0.1)

from rsimsum.

ge-li avatar ge-li commented on June 18, 2024

Yes, that's fantastic!

from rsimsum.

ellessenne avatar ellessenne commented on June 18, 2024

Awesome! I just pushed this updated version to GitHub, you can try it out with:

library(remotes)
remotes::install_github("ellessenne/github")

Let me know your thoughts it you get the chance to play around with it! 😃

from rsimsum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.