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.

111 lines
2.8 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
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. - `stat_logspline`: Computes logspline density (+ counts estimate),
  15. probability, survival & hazard
  16. ## Installation
  17. ``` r
  18. install("gglogspline", repos = "https://cinc.rud.is")
  19. # or
  20. devtools::install_git("https://git.sr.ht/~hrbrmstr/gglogspline.git")
  21. # or
  22. devtools::install_git("https://git.rud.is/hrbrmstr/gglogspline.git")
  23. # or
  24. devtools::install_gitlab("hrbrmstr/gglogspline")
  25. # or
  26. devtools::install_bitbucket("hrbrmstr/gglogspline")
  27. # or
  28. devtools::install_github("hrbrmstr/gglogspline")
  29. ```
  30. ## Usage
  31. ``` r
  32. library(gglogspline)
  33. library(ggplot2)
  34. # current version
  35. packageVersion("gglogspline")
  36. ## [1] '0.1.0'
  37. ```
  38. ``` r
  39. set.seed(1)
  40. data.frame(
  41. val = rnorm(100)
  42. ) -> xdf
  43. ggplot(xdf) +
  44. stat_logspline(aes(val))
  45. ```
  46. <img src="README_files/figure-gfm/unnamed-chunk-1-1.png" width="672" />
  47. ``` r
  48. ggplot(xdf) +
  49. stat_logspline(aes(val, y = stat(count))) +
  50. labs(title = "logspline (count)")
  51. ```
  52. <img src="README_files/figure-gfm/unnamed-chunk-1-2.png" width="672" />
  53. ``` r
  54. ggplot(xdf) +
  55. stat_logspline(aes(val, y = stat(probs))) +
  56. labs(title = "logspline (probability function)")
  57. ```
  58. <img src="README_files/figure-gfm/unnamed-chunk-1-3.png" width="672" />
  59. ``` r
  60. ggplot(xdf) +
  61. stat_logspline(aes(val, y = stat(survival))) +
  62. labs(title = "logspline (survival function)")
  63. ```
  64. <img src="README_files/figure-gfm/unnamed-chunk-1-4.png" width="672" />
  65. ``` r
  66. ggplot(xdf) +
  67. stat_logspline(aes(val, y = stat(hazard))) +
  68. labs(title = "logspline (hazard function)")
  69. ```
  70. <img src="README_files/figure-gfm/unnamed-chunk-1-5.png" width="672" />
  71. ## gglogspline Metrics
  72. | Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
  73. | :--- | -------: | --: | --: | ---: | ----------: | ---: | -------: | ---: |
  74. | R | 4 | 0.8 | 63 | 0.66 | 20 | 0.45 | 53 | 0.59 |
  75. | Rmd | 1 | 0.2 | 32 | 0.34 | 24 | 0.55 | 37 | 0.41 |
  76. ## Code of Conduct
  77. Please note that this project is released with a [Contributor Code of
  78. Conduct](CONDUCT.md). By participating in this project you agree to
  79. abide by its terms.