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.

89 lines
2.2 KiB

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. ## Installation
  22. ```{r install-ex, eval=FALSE}
  23. devtools::install_git("https://git.sr.ht/~hrbrmstr/gglogspline.git")
  24. # or
  25. devtools::install_git("https://git.rud.is/hrbrmstr/gglogspline.git")
  26. # or
  27. devtools::install_gitlab("hrbrmstr/gglogspline")
  28. # or
  29. devtools::install_bitbucket("hrbrmstr/gglogspline")
  30. # or
  31. devtools::install_github("hrbrmstr/gglogspline")
  32. ```
  33. ## Usage
  34. ```{r lib-ex}
  35. library(gglogspline)
  36. library(ggplot2)
  37. # current version
  38. packageVersion("gglogspline")
  39. ```
  40. ```{r}
  41. set.seed(1)
  42. data.frame(
  43. val = rnorm(100)
  44. ) -> xdf
  45. ggplot(xdf) +
  46. stat_logspline(aes(val))
  47. ggplot(xdf) +
  48. stat_logspline(aes(val, y = stat(count))) +
  49. labs(title = "logspline (count)")
  50. ggplot(xdf) +
  51. stat_logspline(aes(val, y = stat(probs))) +
  52. labs(title = "logspline (probability function)")
  53. ggplot(xdf) +
  54. stat_logspline(aes(val, y = stat(survival))) +
  55. labs(title = "logspline (survival function)")
  56. ggplot(xdf) +
  57. stat_logspline(aes(val, y = stat(hazard))) +
  58. labs(title = "logspline (hazard function)")
  59. ```
  60. ## gglogspline Metrics
  61. ```{r cloc, echo=FALSE}
  62. cloc::cloc_pkg_md()
  63. ```
  64. ## Code of Conduct
  65. Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).
  66. By participating in this project you agree to abide by its terms.