Giter Site home page Giter Site logo

Comments (3)

IndrajeetPatil avatar IndrajeetPatil commented on July 29, 2024
library(ggplot2)
library(statsExpressions)
#> Registered S3 methods overwritten by 'lme4':
#>   method                          from
#>   cooks.distance.influence.merMod car 
#>   influence.merMod                car 
#>   dfbeta.influence.merMod         car 
#>   dfbetas.influence.merMod        car

df <- tibble(x = rnorm(100))

df_res <- expr_t_onesample(df, x, output = "dataframe")
#> New names:
#> * ci.width -> ci.width...2
#> * ci.width -> ci.width...8

df_res %<>% dplyr::mutate(expr_sub = list(expr_t_onesample(df, x, type = "p")),
                          expr_cap = list(expr_t_onesample(df, x, type = "bf")))
#> New names:
#> * ci.width -> ci.width...2
#> * ci.width -> ci.width...8
                         
ggplot(df, aes(x)) +
  geom_histogram(alpha = 0.5) +
  labs(
    subtitle = df_res$expr_sub[[1]],
    caption = df_res$expr_cap[[1]]
  )
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2021-01-23 by the reprex package (v0.3.0)

from statsexpressions.

IndrajeetPatil avatar IndrajeetPatil commented on July 29, 2024

expr_template can itself return this as an additional column in a dataframe

this will also avoid having to use substitute and using a list to enter the expression components

from statsexpressions.

IndrajeetPatil avatar IndrajeetPatil commented on July 29, 2024
library(tidyverse)

df <- data.frame(
  term = c("term-1, term-2"),
  p.value = c(0.001, 0.067)
)

(df_label <-
  df %>%
  rowwise() %>%
  mutate(label = list(parse(text = paste0("list(~italic(p)=='", p.value, "')")))))
#> # A tibble: 2 x 3
#> # Rowwise: 
#>   term           p.value label       
#>   <chr>            <dbl> <list>      
#> 1 term-1, term-2   0.001 <expression>
#> 2 term-1, term-2   0.067 <expression>

df_label$label
#> [[1]]
#> expression(list(~italic(p)=='0.001'))
#> 
#> [[2]]
#> expression(list(~italic(p)=='0.067'))

ggplot(mtcars, aes(wt, mpg)) +
  geom_point() +
  labs(subtitle = df_label$label[[1]],
       caption = df_label$label[[2]])

Created on 2021-01-26 by the reprex package (v0.3.0.9001)

from statsexpressions.

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.