cjvanlissa / tidySEM

54 stars 7 forks source link

Curvature specifications #15

Closed samuelVJrobinson closed 3 years ago

samuelVJrobinson commented 3 years ago

I'm having a hard time trying to specify edge curvature. Here's a simple example:

edg <- data.frame(from=c('a','b','a'),to=c('b','c','c')) #Edge specifications
l <- matrix(c('b','c','a',''),nrow=2,byrow = TRUE) #Node locations
g <- prepare_graph(edges=edg,layout=l) #Create graph
plot(g) #Works fine

image

However, say I wanted the a-c edge to have a left-handed curve with a 30 degree angle:

edges(g)$curvature <- c(NA,NA,30) #Wrong curve direction, and arrow has been flipped
plot(g)

image

edges(g)$curvature <- c(NA,NA,-30) #Correct curve direction, but arrow has been flipped
plot(g)

image

What am I doing wrong here? There is no mention of curvature in the plotting vignette, and I'm clearly not understanding what the help files are saying.

cjvanlissa commented 3 years ago

@samuelVJrobinson thank you for reporting this bug in the direction the arrow was pointing, I've addressed this. I'm not sure I agree that the curve also curves in the wrong direction - could you explain why you think so?

To obtain the bugfix, please install the dev version using remotes::install_github("cjvanlissa/tidySEM").

Best, Caspar

samuelVJrobinson commented 3 years ago

Thanks Caspar!

I tried the dev version and it works great. By "curves in the wrong direction", I meant that it was doing the opposite of what I wanted it to do, not that the command itself wasn't working properly.

By the way, I'm using the tidySEM package to display results from a piecewiseSEM model, which is popular with ecologists because of GLM and random effects specification. It doesn't deal with covariances in the same way that lavaan and Mplus do, but piecewiseSEM models might be a useful addition to tidySEM, especially considering that there are not longer any native plotting functions for the models fit by piecewiseSEM. Should I submit this as a feature request?

Thanks for your work! SR

cjvanlissa commented 3 years ago

Samuel, could you email me at c.j.vanlissa (at) uu dot nl?