Giter Site home page Giter Site logo

jthelpers's People

Contributors

jenniferthompson avatar

Watchers

 avatar  avatar

jthelpers's Issues

Update formatp() to NEJM style

"P values larger than 0.01 should be reported to two decimal places, and those between 0.01 and 0.001 to three decimal places; P values smaller than 0.001 should be reported as P<0.001. Notable exceptions to this policy include P values arising from the application of stopping rules to the analysis of clinical trials and from genetic-screening studies."

Account for data sets with no complete rows for a given ID

create_countprocess_data() breaks if

  • there are no rows with complete data for a given ID
  • data.set[, time.var] is missing for a given ID

Might be good to fix that. Or at least give better warnings so people know to take care of it on the front end.

Also, let people name the status variable something other than died. Confusing when the event isn't death.

Add function to make rms_model_results() into a huxtable

Originally written for DelDepLTCI

## -- Function to make huxtable from rms_model_results() df + col headers ------
make_modresults_ht <- function(resultsdf){
  ht <- resultsdf %>%
    hux() %>%
    ## Align variable name to left, all other columns to right
    set_align(row = everywhere, col = everywhere, byrow = TRUE,
              value = c("left", rep("right", ncol(resultsdf) - 1))) %>%
    ## Set p-value column to three decimal places by default
    set_number_format(row = everywhere, col = 7, value = 3) %>%
    ## Bold column headers, add line after first row
    set_bold(row = 1, col = everywhere, TRUE) %>%
    set_bottom_border(row = 1, col = everywhere, value = 1) %>%
    ## Gray out all info except the row for history of depression, our main
    ## exposure of interest
    set_text_color(
      row = grep("^hx\\.depression$", resultsdf$label, invert = TRUE),
      col = everywhere,
      value = "#838383"
    ) %>%
    ## Table should take up 90% of document width
    set_width(0.9)
}

rms_model_results(): Bug fix for Gls models

Many thanks to Yonghao Pua for catching this and creating a reprex.

Currently, rms_model_results() works beautifully with ols and lrm objects but I'm wondering if you could very kindly extend its reach to Gls objects. With orm objects, rms_model_results() works reasonably well; with Gls objects, it balks with an error message: "Error in label == "d.f." : comparison (1) is possible only for atomic and list types". Below, I provide a minimal example.

rm(list=ls())
library(plyr)
library(dplyr)
library(tidyr)
library(rms)
library(JTHelpers)

# create tall-and-thin longitudinal dataframe 
longdf <- data.frame(
    expand.grid(id = seq(1:10), time = 1:5), outcome = round(runif(50, 2, 12), 0)
)

longdf <- longdf %>%
  arrange(id, time) %>%
  mutate( age = rep(round(runif(10, 20, 60),0), each = 5 ))

longdf.dd <- datadist(longdf); options(datadist = "longdf.dd")

glsmod <-Gls(outcome~ time + rcs(age,3), correlation = corCAR1 (form=~time|id), data=longdf)

glsmod; summary(glsmod); anova(glsmod)

rms_model_results(glsmod)  # throws error mesage

Error in label == "d.f." : comparison (1) is possible only for atomic and list types

Add Rmd template

Ideas:

  • Session info/R version
  • Author + date info
  • ggplot theme?

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.