Giter VIP home page Giter VIP logo

kfbmisc's Introduction

kfbmisc

kfbmisc is a package full of utility function I find useful

Installation

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

# install.packages("devtools")
devtools::install_github("kylebutts/kfbmisc")

Utilities

library(kfbmisc)

ggplot2 theme

This is a relatively simple theme that makes the font larger for figures and adds more margins around things.

library(ggplot2)

ggplot(mtcars) +
  geom_point(aes(x = mpg, y = hp)) +
  labs(
    title = "mtcars Dataset",
    x = "Miles per Gallon", y = "Horsepower"
  ) +
  theme_kyle(base_size = 14)

ggplot(mtcars) +
  geom_point(aes(x = mpg, y = hp)) +
  facet_wrap(~cyl) +
  labs(
    title = "mtcars Dataset",
    x = "Miles per Gallon", y = "Horsepower"
  ) +
  theme_kyle(base_size = 14)

library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
nc <- st_read(system.file("shape/nc.shp", package="sf"))
#> Reading layer `nc' from data source 
#>   `/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/sf/shape/nc.shp' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 100 features and 14 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> Geodetic CRS:  NAD27

ggplot(nc) +
  geom_sf(aes(fill = BIR74)) +
  scale_fill_viridis_c() + 
  theme_kyle(base_size = 14) + 
  theme_map()

gt theme

This theme borrow heavily from Thomas Mock

library(gt)

mtcars[1:5, ] |>
  gt() |>
  gt_theme_kyle() |>
  tab_header(title = make_gt_title("mtcars Dataset")) |>
  tab_source_note(source_note = "Data from mtcars in R") |>
  as_raw_html()
mtcars Dataset
mpg cyl disp hp drat wt qsec vs am gear carb
21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
Data from mtcars in R

kfbmisc's People

Contributors

kylebutts 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.