A 'ggplot2' Extension for Visualizing Density, Distribution, Hazard, or Survival Functions using the 'logspline' Package
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.6 KiB

1 year ago
1 year ago
1 year ago
  1. [![Travis-CI Build
  2. Status](https://travis-ci.org/hrbrmstr/gglogspline.svg?branch=master)](https://travis-ci.org/hrbrmstr/gglogspline)
  3. [![Coverage
  4. Status](https://codecov.io/gh/hrbrmstr/gglogspline/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/gglogspline)
  5. [![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/gglogspline)](https://cran.r-project.org/package=gglogspline)
  6. # gglogspline
  7. A ‘ggplot2’ Extension for Visualizing Density, Distribution, Hazard, or
  8. Survival Functions using the ‘logspline’ Package
  9. ## Description
  10. Methods are provided to plot a logspline density, distribution function,
  11. hazard function or survival function from a logspline density
  12. ## What’s Inside The Tin
  13. The following functions are implemented:
  14. ## Installation
  15. ``` r
  16. devtools::install_git("https://git.sr.ht/~hrbrmstr/gglogspline.git")
  17. # or
  18. devtools::install_git("https://git.rud.is/hrbrmstr/gglogspline.git")
  19. # or
  20. devtools::install_gitlab("hrbrmstr/gglogspline")
  21. # or
  22. devtools::install_bitbucket("hrbrmstr/gglogspline")
  23. # or
  24. devtools::install_github("hrbrmstr/gglogspline")
  25. ```
  26. ## Usage
  27. ``` r
  28. library(gglogspline)
  29. library(ggplot2)
  30. # current version
  31. packageVersion("gglogspline")
  32. ## [1] '0.1.0'
  33. ```
  34. ``` r
  35. set.seed(1)
  36. data.frame(
  37. val = rnorm(100)
  38. ) -> xdf
  39. ggplot(xdf) +
  40. stat_logspline(aes(val))
  41. ```
  42. <img src="README_files/figure-gfm/unnamed-chunk-1-1.png" width="672" />
  43. ``` r
  44. ggplot(xdf) +
  45. stat_logspline(aes(val, y = stat(count))) +
  46. labs(title = "logspline (count)")
  47. ```
  48. <img src="README_files/figure-gfm/unnamed-chunk-1-2.png" width="672" />
  49. ``` r
  50. ggplot(xdf) +
  51. stat_logspline(aes(val, y = stat(probs))) +
  52. labs(title = "logspline (probability function)")
  53. ```
  54. <img src="README_files/figure-gfm/unnamed-chunk-1-3.png" width="672" />
  55. ``` r
  56. ggplot(xdf) +
  57. stat_logspline(aes(val, y = stat(survival))) +
  58. labs(title = "logspline (survival function)")
  59. ```
  60. <img src="README_files/figure-gfm/unnamed-chunk-1-4.png" width="672" />
  61. ``` r
  62. ggplot(xdf) +
  63. stat_logspline(aes(val, y = stat(hazard))) +
  64. labs(title = "logspline (hazard function)")
  65. ```
  66. <img src="README_files/figure-gfm/unnamed-chunk-1-5.png" width="672" />
  67. ## gglogspline Metrics
  68. | Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
  69. | :--- | -------: | --: | --: | ---: | ----------: | ---: | -------: | --: |
  70. | R | 4 | 0.8 | 63 | 0.67 | 20 | 0.47 | 53 | 0.6 |
  71. | Rmd | 1 | 0.2 | 31 | 0.33 | 23 | 0.53 | 35 | 0.4 |
  72. ## Code of Conduct
  73. Please note that this project is released with a [Contributor Code of
  74. Conduct](CONDUCT.md). By participating in this project you agree to
  75. abide by its terms.