GithubHelp home page GithubHelp logo

ggbroom's Introduction

{vizbroom}

Installation

You can install the development version of vizbroom from GitHub with:

# install.packages("devtools")
devtools::install_github("EvaMaeRey/vizbroom")

User interface idea…

library(ggplot2) 
library(ggbroom)

visbroom(data = ?, formula = ?, method = ?) + 
  viz_glance()

visbroom(data = ?, formula = ?, method = ?) + 
  viz_tidy()

visbroom(data = ?, formula = ?, method = ?) + 
  viz_tidy_stdz()

visbroom(data = ?, formula = ?, method = ? ) + 
  viz_augment()

visbroom(data = ?, formula = ?, method = ? ) + 
  viz_augment_stdz()

How we built this functionality

Step 0. Build vis with base ggplot2 and broom

library(broom)
# glance
# augment
# tidy
stdz <- function(x){
  
  (x - mean(x))/sd(x)
  
}

m <- lm(dist ~ speed, data = cars)





glance(m) 
#> # A tibble: 1 × 12
#>   r.squared adj.r.squared sigma statistic  p.value    df logLik   AIC   BIC
#>       <dbl>         <dbl> <dbl>     <dbl>    <dbl> <dbl>  <dbl> <dbl> <dbl>
#> 1     0.651         0.644  15.4      89.6 1.49e-12     1  -207.  419.  425.
#> # ℹ 3 more variables: deviance <dbl>, df.residual <int>, nobs <int>
tidy(m)
#> # A tibble: 2 × 5
#>   term        estimate std.error statistic  p.value
#>   <chr>          <dbl>     <dbl>     <dbl>    <dbl>
#> 1 (Intercept)   -17.6      6.76      -2.60 1.23e- 2
#> 2 speed           3.93     0.416      9.46 1.49e-12
augment(m) |> head()
#> # A tibble: 6 × 8
#>    dist speed .fitted .resid   .hat .sigma  .cooksd .std.resid
#>   <dbl> <dbl>   <dbl>  <dbl>  <dbl>  <dbl>    <dbl>      <dbl>
#> 1     2     4   -1.85   3.85 0.115    15.5 0.00459       0.266
#> 2    10     4   -1.85  11.8  0.115    15.4 0.0435        0.819
#> 3     4     7    9.95  -5.95 0.0715   15.5 0.00620      -0.401
#> 4    22     7    9.95  12.1  0.0715   15.4 0.0255        0.813
#> 5    16     8   13.9    2.12 0.0600   15.5 0.000645      0.142
#> 6    10     9   17.8   -7.81 0.0499   15.5 0.00713      -0.521


library(ggplot2)
library(magrittr)

glance(m) %>%  
  tidyr::pivot_longer(cols = 1:length(.)) %>% 
  dplyr::mutate(which = dplyr::row_number()) %>% 
ggplot(data = .) + 
  aes(x = 0, y = which) + 
  geom_text(aes(label = name), hjust = 0 ) + 
  geom_text(aes(label = value, x = 1), hjust = 1)

tidy(m) |>
  ggplot() + 
  aes(y = term, x = estimate) + 
  geom_point() + 
  geom_segment(aes(x = estimate + std.error,
                   xend = estimate - std.error,
                   yend = term))

lm(stdz(dist) ~ stdz(speed), data = cars) |>
 tidy() |>
  ggplot() + 
  aes(y = term, x = estimate) + 
  geom_point() + 
  geom_segment(aes(x = estimate + std.error,
                   xend = estimate - std.error,
                   yend = term))

ggplot(data = augment(m)) + 
  aes(x = speed, y = dist) + 
  geom_point() + 
  geom_point(aes(y = .fitted), color = "blue")

Write functions w/ ‘recipe’ substeps: 1. compute_?; 2. define ggproto; 3. write geom_*; 4. test.

Write geom_county() (polygon)

################# Step 1. Compute panel function ###########

###### Step 2. Specify ggproto ###############

########### Step 3. geom function, inherits from sf ##################

try it out..

ggbroom's People

Contributors

evamaerey avatar

Stargazers

boB Rudis avatar

Watchers

 avatar

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.