MyNixOS website logo
Description

Veras Miscellaneous.

Contains a collection of useful functions for basic data computation and manipulation, wrapper functions for generating 'ggplot2' graphics, including statistical model diagnostic plots, methods for computing statistical models quality measures (such as AIC, BIC, r squared, root mean squared error) and general utilities.

lvmisc

R buildstatus CRANstatus Codecov testcoverage

lvmisc is a package with miscellaneous R functions, including basic data computation/manipulation, easy plotting and tools for working with statistical models objects. You can learn more about the methods for working with models in vignette("working_with_models").

Installation

You can install the released version of lvmisc from CRAN with:

install.packages("lvmisc")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("verasls/lvmisc")

Getting started

Some of what you can do with lvmisc.

library(lvmisc)
library(dplyr)

# Compute body mass index (BMI) and categorize it
starwars %>%
  select(name, birth_year, mass, height) %>%
  mutate(
    BMI = bmi(mass, height / 100),
    BMI_category = bmi_cat(BMI)
  )
#> # A tibble: 87 × 6
#>    name               birth_year  mass height   BMI BMI_category    
#>    <chr>                   <dbl> <dbl>  <int> <dbl> <fct>           
#>  1 Luke Skywalker           19      77    172  26.0 Overweight      
#>  2 C-3PO                   112      75    167  26.9 Overweight      
#>  3 R2-D2                    33      32     96  34.7 Obesity class I 
#>  4 Darth Vader              41.9   136    202  33.3 Obesity class I 
#>  5 Leia Organa              19      49    150  21.8 Normal weight   
#>  6 Owen Lars                52     120    178  37.9 Obesity class II
#>  7 Beru Whitesun lars       47      75    165  27.5 Overweight      
#>  8 R5-D4                    NA      32     97  34.0 Obesity class I 
#>  9 Biggs Darklighter        24      84    183  25.1 Overweight      
#> 10 Obi-Wan Kenobi           57      77    182  23.2 Normal weight   
#> # … with 77 more rows

# Divide numerical variables in quantiles
divide_by_quantile(mtcars$wt, 4)
#>  [1] 2 2 1 2 3 3 3 2 2 3 3 4 4 4 4 4 4 1 1 1 1 3 3 4 4 1 1 1 2 2 3 2
#> Levels: 1 2 3 4

# Center and scale variables by group
center_variable(iris$Petal.Width, by = iris$Species, scale = TRUE)
#>   [1] -0.046 -0.046 -0.046 -0.046 -0.046  0.154  0.054 -0.046 -0.046 -0.146
#>  [11] -0.046 -0.046 -0.146 -0.146 -0.046  0.154  0.154  0.054  0.054  0.054
#>  [21] -0.046  0.154 -0.046  0.254 -0.046 -0.046  0.154 -0.046 -0.046 -0.046
#>  [31] -0.046  0.154 -0.146 -0.046 -0.046 -0.046 -0.046 -0.146 -0.046 -0.046
#>  [41]  0.054  0.054 -0.046  0.354  0.154  0.054 -0.046 -0.046 -0.046 -0.046
#>  [51]  0.074  0.174  0.174 -0.026  0.174 -0.026  0.274 -0.326 -0.026  0.074
#>  [61] -0.326  0.174 -0.326  0.074 -0.026  0.074  0.174 -0.326  0.174 -0.226
#>  [71]  0.474 -0.026  0.174 -0.126 -0.026  0.074  0.074  0.374  0.174 -0.326
#>  [81] -0.226 -0.326 -0.126  0.274  0.174  0.274  0.174 -0.026 -0.026 -0.026
#>  [91] -0.126  0.074 -0.126 -0.326 -0.026 -0.126 -0.026 -0.026 -0.226 -0.026
#> [101]  0.474 -0.126  0.074 -0.226  0.174  0.074 -0.326 -0.226 -0.226  0.474
#> [111] -0.026 -0.126  0.074 -0.026  0.374  0.274 -0.226  0.174  0.274 -0.526
#> [121]  0.274 -0.026 -0.026 -0.226  0.074 -0.226 -0.226 -0.226  0.074 -0.426
#> [131] -0.126 -0.026  0.174 -0.526 -0.626  0.274  0.374 -0.226 -0.226  0.074
#> [141]  0.374  0.274 -0.126  0.274  0.474  0.274 -0.126 -0.026  0.274 -0.226

# Quick and easy plotting with {ggplot}
plot_scatter(mtcars, disp, mpg, color = factor(cyl))

# Work with statistical model objects
m <- lm(disp ~ mpg + hp + cyl + mpg:cyl, mtcars)
accuracy(m)
#>      AIC    BIC   R2 R2_adj  MAE   MAPE  RMSE
#> 1 344.64 353.43 0.87   0.85 34.9 15.73% 43.75
plot_model(m)
Metadata

Version

0.1.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows