Hello STATALIST users,
I am having trouble with some code to draw a spaghetti plot. Each time I run the code it brings back an error "graph Graph not found" and I cannot see where I am going wrong.
return code:
I have tried this where I have taken out the first loop "foreach obj in B2b {" and the response it gave was:
Is there a way around this? each line I am drawing is for a different participant.
I am having trouble with some code to draw a spaghetti plot. Each time I run the code it brings back an error "graph Graph not found" and I cannot see where I am going wrong.
Code:
foreach obj in B2b {
foreach analyte of varlist NfL GFAP Tau {
cd ..
cd "3. Graphs"
cd "`obj'"
cd `analyte'
foreach col_type in Venepuncture Finger-prick {
preserve
drop if Objective!="`obj'" | ///
`analyte'==. | ///
CollectionType!="`col_type'"
capture ///
xtline `analyte' , i(ID_visit) t(sample_delay1) ///
overlay legend(off) aspectratio(1) ///
xlabel("``obj'xlab`col_type''", valuelabel) ///
ylabel(``obj'`analyte'ylab') ///
yscale(range(``obj'`analyte'y')) xscale(lwidth(thick)) yscale(lwidth(thick)) ///
``obj'xaxis`col_type'' ///
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
// name(`obj'_`analyte'_`col_type', replace)
graph save "`analyte'_`obj'_`col_type'_Spag_plot.gph" , replace
graph export "`analyte'_`obj'_`col_type'_Spag_plot.png" , replace
graph export "`analyte'_`obj'_`col_type'_Spag_plot.eps" , replace
restore
}
cd ..
cd ..
cd ..
cd "2. dta files"
}
}
Code:
graph Graph not found r(111);
Code:
could not find Graph window r(693);
