有可能做到这一点更简单的方法(和忽略,如果它是明智的做) - 一种方式您可以通过在绘图之前从对象中删除节点来完成此操作。
从你的问题Rotate Edges in semPaths/qgraph
library(qgraph)
library(semPlot)
library(MplusAutomation)
# This downloads an output file from Mplus examples
download.file("http://www.statmodel.com/usersguide/chap5/ex5.8.out",
outfile <- tempfile(fileext = ".out"))
# Unadjusted plot
s <- semPaths(outfile, intercepts = FALSE)
使用Mplus例如在上面的调用semPaths
,outfile
是character
类的,太行(代码为semPaths
附近开始)
if (!"semPlotModel" %in% class(object))
object <- do.call(semPlotModel, c(list(object), modelOpts))
返回对象semPlot:::semPlotModel.mplus.model(outfile)
。这是类"semPlotModel"
。
所以这个想法是先创建这个对象,修改它,然后将这个对象传递给semPaths
。
# Call semPlotModel on your Mplus file
obj <- semPlot:::semPlotModel.mplus.model(outfile)
# obj <- do.call(semPlotModel, list(outfile)) # this is more general/not just for Mplus
# Remove one factor (F1) from [email protected] - need to check lhs and rhs columns
idx <- apply([email protected][c("lhs", "rhs")], 1, function(i) any(grepl("F1", i)))
[email protected] <- [email protected][!idx, ]
class(obj)
obj
现在是"semPlotModel"
类的,可以直接传递到semPaths
s <- semPaths(obj, intercepts = FALSE)
您可以使用str(s)
看到这个结构返回的对象。
向我们展示数据结构。尝试发布'str(x)'的输出,甚至更好,做一个[可重现的例子](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)。 – 2014-10-06 10:49:04
我刚刚从Mplus上传了OUTfile。感谢您的建议:) – 2014-10-06 11:06:45
我建议您将代码嵌入到您的答案中,以便在您从Dropbox中移除文件后,问题不会过时。 – 2014-10-06 11:25:47