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.

93 lines
2.4 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. ---
  2. output: rmarkdown::github_document
  3. editor_options:
  4. chunk_output_type: inline
  5. ---
  6. ```{r pkg-knitr-opts, include=FALSE}
  7. knitr::opts_chunk$set(
  8. collapse = TRUE, fig.retina = 2, message = FALSE, warning = FALSE
  9. )
  10. options(width=120)
  11. ```
  12. [![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/gglogspline.svg?branch=master)](https://travis-ci.org/hrbrmstr/gglogspline)
  13. [![Coverage Status](https://codecov.io/gh/hrbrmstr/gglogspline/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/gglogspline)
  14. [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/gglogspline)](https://cran.r-project.org/package=gglogspline)
  15. # gglogspline
  16. A 'ggplot2' Extension for Visualizing Density, Distribution, Hazard, or Survival Functions using the 'logspline' Package
  17. ## Description
  18. Methods are provided to plot a logspline density, distribution function, hazard function or survival function from a logspline density
  19. ## What's Inside The Tin
  20. The following functions are implemented:
  21. - `stat_logspline`: Computes logspline density (+ counts estimate), probability, survival & hazard
  22. ## Installation
  23. ```{r install-ex, eval=FALSE}
  24. install("gglogspline", repos = "https://cinc.rud.is")
  25. # or
  26. devtools::install_git("https://git.sr.ht/~hrbrmstr/gglogspline.git")
  27. # or
  28. devtools::install_git("https://git.rud.is/hrbrmstr/gglogspline.git")
  29. # or
  30. devtools::install_gitlab("hrbrmstr/gglogspline")
  31. # or
  32. devtools::install_bitbucket("hrbrmstr/gglogspline")
  33. # or
  34. devtools::install_github("hrbrmstr/gglogspline")
  35. ```
  36. ## Usage
  37. ```{r lib-ex}
  38. library(gglogspline)
  39. library(ggplot2)
  40. # current version
  41. packageVersion("gglogspline")
  42. ```
  43. ```{r}
  44. set.seed(1)
  45. data.frame(
  46. val = rnorm(100)
  47. ) -> xdf
  48. ggplot(xdf) +
  49. stat_logspline(aes(val))
  50. ggplot(xdf) +
  51. stat_logspline(aes(val, y = stat(count))) +
  52. labs(title = "logspline (count)")
  53. ggplot(xdf) +
  54. stat_logspline(aes(val, y = stat(probs))) +
  55. labs(title = "logspline (probability function)")
  56. ggplot(xdf) +
  57. stat_logspline(aes(val, y = stat(survival))) +
  58. labs(title = "logspline (survival function)")
  59. ggplot(xdf) +
  60. stat_logspline(aes(val, y = stat(hazard))) +
  61. labs(title = "logspline (hazard function)")
  62. ```
  63. ## gglogspline Metrics
  64. ```{r cloc, echo=FALSE}
  65. cloc::cloc_pkg_md()
  66. ```
  67. ## Code of Conduct
  68. Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).
  69. By participating in this project you agree to abide by its terms.