lavaanPlot

R package for plotting lavaan path models with DiagrammeR

https://github.com/alishinski/lavaanplot

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.1%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

R package for plotting lavaan path models with DiagrammeR

Basic Info
Statistics
  • Stars: 43
  • Watchers: 5
  • Forks: 6
  • Open Issues: 18
  • Releases: 0
Created about 9 years ago · Last pushed about 2 years ago
Metadata Files
Readme Changelog

README.Rmd

---
output: github_document
always_allow_html: true
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

[![CRAN status](https://www.r-pkg.org/badges/version/lavaanPlot)](https://cran.r-project.org/package=lavaanPlot)
[![](https://cranlogs.r-pkg.org/badges/lavaanPlot)](https://cran.r-project.org/package=lavaanPlot)
[![R-CMD-check](https://github.com/alishinski/lavaanPlot/workflows/R-CMD-check/badge.svg)](https://github.com/alishinski/lavaanPlot/actions)

## News

Version 0.7.0, is introducing a new iteration of the `lavaanPlot` function, called `lavaanPlot2`. Check out a new vignette explaining some of the changes here: [Improvements to lavaanPlot](https://lavaanplot.alexlishinski.com/improvements_to_lavaanplot)

Version 0.8.0, is introducing conditional formatting to the `lavaanPlot` package, using the new `formatting` function. Check out the new vignette explaining the changes here: [Conditional Formatting in LavaanPlot](https://lavaanplot.alexlishinski.com/Conditional_Formatting)

## Background

The lavaan package is an excellent package for structural equation models, and the DiagrammeR package is an excellent package for producing nice looking graph diagrams. As of right now, the lavaan package has no built in plotting functions for models, and the available options from external packages don't look as nice and aren't as easy to use as DiagrammeR, in my opinion. Of course, you can use DiagrammeR to build path diagrams for your models, but it requires you to build the diagram specification manually. This package exists to streamline that process, allowing you to plot your lavaan models directly, without having to translate them into the DOT language specification that DiagrammeR uses.

## Installation

You can install lavaanPlot from CRAN with:

```{r, eval = F}
install.packages("lavaanPlot")
```

You can also install the development version of lavaanPlot from GitHub with:

```{r gh-installation, eval = FALSE}
install.packages("devtools")
devtools::install_github("alishinski/lavaanPlot")
```

## Examples

Here's a quick example using the `mtcars` data set. 

First fit your lavaan model. The package supports plotting lavaan regression relationships and latent variable - indicator relationships.

```{r}
library(lavaan)
library(lavaanPlot)

model <- 'mpg ~ cyl + disp + hp
          qsec ~ disp + hp + wt'

fit <- sem(model, data = mtcars)
summary(fit)
```

Then using that model fit object, simply call the `lavaanPlot` function, specifying your desired graph parameters.

```{r}
lavaanPlot(model = fit, node_options = list(shape = "box", fontname = "Helvetica"), edge_options = list(color = "grey"), coefs = F)
```

There is also functionality to save these plots as images and embed them in pdf output documents.

```{r, eval = FALSE}
model <- 'mpg ~ cyl + disp + hp
          qsec ~ disp + hp + wt'

fit <- sem(model, data = mtcars)

pl <- lavaanPlot(model = fit)

# Example for pdf embed
embed_plot_pdf(pl, "plot2.pdf")

# Example for saving to .png
save_png(pl, "plot.png")
```

# Learning More

To learn more, check out the vignettes.


## Citing lavaanPlot

If you found lavaanPlot useful and used the plots in a publication, I ask that you please cite the package. 

## Contributing

I welcome any and all contributions from people using the package, so please share github issues here if there are problems you encounter or features you want to suggest.

Owner

  • Name: Alex Lishinski
  • Login: alishinski
  • Kind: user
  • Location: Washington DC

GitHub Events

Total
  • Issues event: 3
  • Watch event: 6
  • Issue comment event: 5
  • Push event: 1
  • Pull request event: 1
  • Fork event: 1
Last Year
  • Issues event: 3
  • Watch event: 6
  • Issue comment event: 5
  • Push event: 1
  • Pull request event: 1
  • Fork event: 1

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 52
  • Total Committers: 2
  • Avg Commits per committer: 26.0
  • Development Distribution Score (DDS): 0.058
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Alex Lishinski a****i@g****m 49
Pavel N. Krivitsky p****y@u****u 3
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 49
  • Total pull requests: 3
  • Average time to close issues: 7 months
  • Average time to close pull requests: 18 days
  • Total issue authors: 33
  • Total pull request authors: 3
  • Average comments per issue: 2.71
  • Average comments per pull request: 1.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 2
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • jorgesinval (9)
  • alishinski (6)
  • rempsyc (2)
  • willynilly (2)
  • jebyrnes (2)
  • Buedenbender (1)
  • maxnormaal (1)
  • isaactpetersen (1)
  • dohdoubleg (1)
  • igavronski (1)
  • SilviaMorgenstern (1)
  • waurimal1 (1)
  • mccarthy-m-g (1)
  • tdienlin (1)
  • zby0327 (1)
Pull Request Authors
  • isaactpetersen (1)
  • krivit (1)
  • alishinski (1)
  • rikhuijzer (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 3,208 last-month
  • Total docker downloads: 17
  • Total dependent packages: 1
  • Total dependent repositories: 2
  • Total versions: 6
  • Total maintainers: 1
cran.r-project.org: lavaanPlot

Path Diagrams for 'Lavaan' Models via 'DiagrammeR'

  • Versions: 6
  • Dependent Packages: 1
  • Dependent Repositories: 2
  • Downloads: 3,208 Last month
  • Docker Downloads: 17
Rankings
Stargazers count: 8.2%
Downloads: 8.6%
Forks count: 12.2%
Average: 14.9%
Dependent packages count: 18.1%
Dependent repos count: 19.2%
Docker downloads count: 23.1%
Maintainers (1)
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • DiagrammeR * imports
  • dplyr * imports
  • lavaan * imports
  • magrittr * imports
  • purrr * imports
  • rlang * imports
  • stringr * imports
  • DiagrammeRsvg * suggests
  • knitr * suggests
  • png * suggests
  • rmarkdown * suggests
  • rsvg * suggests
  • testthat >= 3.0.0 suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/upload-artifact v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-tinytex v1 composite
.github/workflows/pkgdown.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r-dependencies v1 composite