https://github.com/hrbrmstr/gglogspline
📈A 'ggplot2' Extension for Visualizing Density, Distribution, Hazard, or Survival Functions using the 'logspline' Package
https://github.com/hrbrmstr/gglogspline
ggplot-extension ggplot2 log-density logspline r rstats
Last synced: 12 months ago
JSON representation
📈A 'ggplot2' Extension for Visualizing Density, Distribution, Hazard, or Survival Functions using the 'logspline' Package
- Host: GitHub
- URL: https://github.com/hrbrmstr/gglogspline
- Owner: hrbrmstr
- Created: 2019-06-17T20:08:00.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-18T21:07:44.000Z (about 7 years ago)
- Last Synced: 2025-04-09T02:41:30.097Z (about 1 year ago)
- Topics: ggplot-extension, ggplot2, log-density, logspline, r, rstats
- Language: R
- Homepage:
- Size: 233 KB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: inline
---
```{r pkg-knitr-opts, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE, fig.retina = 2, message = FALSE, warning = FALSE
)
options(width=120)
```
[](https://travis-ci.org/hrbrmstr/gglogspline)
[](https://codecov.io/gh/hrbrmstr/gglogspline)
[](https://cran.r-project.org/package=gglogspline)
# gglogspline
A 'ggplot2' Extension for Visualizing Density, Distribution, Hazard, or Survival Functions using the 'logspline' Package
## Description
Methods are provided to plot a logspline density, distribution function, hazard function or survival function from a logspline density
## What's Inside The Tin
The following functions are implemented:
- `stat_logspline`: Computes logspline density (+ counts estimate), probability, survival & hazard
## Installation
```{r install-ex, eval=FALSE}
install("gglogspline", repos = "https://cinc.rud.is")
# or
devtools::install_git("https://git.sr.ht/~hrbrmstr/gglogspline.git")
# or
devtools::install_git("https://git.rud.is/hrbrmstr/gglogspline.git")
# or
devtools::install_gitlab("hrbrmstr/gglogspline")
# or
devtools::install_bitbucket("hrbrmstr/gglogspline")
# or
devtools::install_github("hrbrmstr/gglogspline")
```
## Usage
```{r lib-ex}
library(gglogspline)
library(ggplot2)
# current version
packageVersion("gglogspline")
```
```{r}
set.seed(1)
data.frame(
val = rnorm(100)
) -> xdf
ggplot(xdf) +
stat_logspline(aes(val))
ggplot(xdf) +
stat_logspline(aes(val, y = stat(count))) +
labs(title = "logspline (count)")
ggplot(xdf) +
stat_logspline(aes(val, y = stat(probs))) +
labs(title = "logspline (probability function)")
ggplot(xdf) +
stat_logspline(aes(val, y = stat(survival))) +
labs(title = "logspline (survival function)")
ggplot(xdf) +
stat_logspline(aes(val, y = stat(hazard))) +
labs(title = "logspline (hazard function)")
```
## gglogspline Metrics
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).
By participating in this project you agree to abide by its terms.