makeawk <- function(latent){ cat("BEGIN {",sep="\n",file="lavaan_dot.awk") cat("i = 0",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"digraph fit \\{\"",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"rankdir=TB;\"",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"size=\\\"8,8\\\";\"",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"edge [fontname=\\\"sans\\\" ,fontsize=8,arrowsize = 0.8,penwidth=0.8];\"",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"graph [ordering = out,splines = true,overlap = false];\"",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"center=1;\"",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"node [shape =ellipse, style = filled,fillcolor = \\\"#f4fd78\\\"];",sep=" ",append=T,file="lavaan_dot.awk") cat(latent,sep=" ",append=T,file="lavaan_dot.awk") cat(";\"",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"node [fontname=\\\"serif\\\" ,fontsize=14, shape=box, style = filled,fillcolor = \\\"#a9fab1\\\"];\"",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"{rank=min };\"",sep="\n",append=T,file="lavaan_dot.awk") cat("}",sep="\n",append=T,file="lavaan_dot.awk") cat("{",sep="\n",append=T,file="lavaan_dot.awk") cat("if($2 == \"=~\")",sep="\n",append=T,file="lavaan_dot.awk") cat("{",sep="\n",append=T,file="lavaan_dot.awk") cat("print $1 \"->\" $3 $4 $5 $6",sep="\n",append=T,file="lavaan_dot.awk") cat("}",sep="\n",append=T,file="lavaan_dot.awk") cat("if($2 == \"~\")",sep="\n",append=T,file="lavaan_dot.awk") cat("{",sep="\n",append=T,file="lavaan_dot.awk") cat("print $1 \"->\" $3 $4 $5 \",dir=back\" $6",sep="\n",append=T,file="lavaan_dot.awk") cat("}",sep="\n",append=T,file="lavaan_dot.awk") cat("if($2 == \"~~\")",sep="\n",append=T,file="lavaan_dot.awk") cat("{",sep="\n",append=T,file="lavaan_dot.awk") cat("print $1 \"->\" $3 $4 $5 \",dir=both\" $6",sep="\n",append=T,file="lavaan_dot.awk") cat("}",sep="\n",append=T,file="lavaan_dot.awk") cat("if($2 == \"~1\")",sep="\n",append=T,file="lavaan_dot.awk") cat("{",sep="\n",append=T,file="lavaan_dot.awk") cat("i = i + 1",sep="\n",append=T,file="lavaan_dot.awk") cat("print $1 \"-> 切片\" i $3 $4 \",dir=back\" $5",sep="\n",append=T,file="lavaan_dot.awk") cat("}",sep="\n",append=T,file="lavaan_dot.awk") cat("}",sep="\n",append=T,file="lavaan_dot.awk") cat("END{",sep="\n",append=T,file="lavaan_dot.awk") cat("print \"\\}\"",sep="\n",append=T,file="lavaan_dot.awk") cat("}",sep="\n",append=T,file="lavaan_dot.awk") }
|