[Rd] "What Calls What" diagram. Flow Chart?
William Dunlap
wdunlap at tibco.com
Mon Oct 10 18:03:21 CEST 2011
Have you tried using trace()? E.g.,
> library(lavaan)
> trace(lavaan)
> HS.model <- ' visual =~ x1 + x2 + x3
+ textual =~ x4 + x5 + x6
+ speed =~ x7 + x8 + x9 '
>
> fit <- cfa(HS.model, data=HolzingerSwineford1939)
trace: lavaan(model.syntax = HS.model, data = HolzingerSwineford1939,
model.type = "cfa", int.ov.free = TRUE, int.lv.free = FALSE,
auto.fix.first = TRUE, auto.fix.single = TRUE, auto.var = TRUE,
auto.cov.lv.x = TRUE, auto.cov.y = TRUE)
or, to see who is calling what and what eval is evaluating,
> trace(lavaan, quote(cat(sapply(sys.calls(), function(e)deparse(e)[1]), sep="\n ")))
Tracing function "lavaan" in package "lavaan"
[1] "lavaan"
> trace(eval, quote(cat(" ", deparse(expr), "\n")))
Tracing function "eval" in package "base"
[1] "eval"
> HS.model <- ' visual =~ x1 + x2 + x3
+ textual =~ x4 + x5 + x6
+ speed =~ x7 + x8 + x9 '
>
> fit <- cfa(HS.model, data=HolzingerSwineford1939)
Tracing eval(mc, parent.frame()) on entry
lavaan(model.syntax = HS.model, data = HolzingerSwineford1939, model.type = "cfa", int.ov.free = TRUE, int.lv.free = FALSE, auto.fix.first = TRUE, auto.fix.single = TRUE, auto.var = TRUE, auto.cov.lv.x = TRUE, auto.cov.y = TRUE)
Tracing lavaan(model.syntax = HS.model, data = HolzingerSwineford1939, .... on entry
cfa(HS.model, data = HolzingerSwineford1939)
eval(mc, parent.frame())
eval(expr, envir, enclos)
lavaan(model.syntax = HS.model, data = HolzingerSwineford1939,
.doTrace(cat(sapply(sys.calls(), function(e) deparse(e)[1]),
eval.parent(exprObj)
eval(expr, p)
eval(expr, envir, enclos)
Tracing eval(parse(text = x)[[1L]]) on entry
~visual
Tracing eval(parse(text = x)[[1L]]) on entry
~x1 + x2 + x3
Tracing eval(parse(text = x)[[1L]]) on entry
~textual
Tracing eval(parse(text = x)[[1L]]) on entry
~x4 + x5 + x6
Tracing eval(parse(text = x)[[1L]]) on entry
~speed
Tracing eval(parse(text = x)[[1L]]) on entry
~x7 + x8 + x9
Tracing eval(formal.args[[deparse(substitute(arg))]]) on entry
c("no", "ifany", "always")
Tracing eval(formal.args[[deparse(substitute(arg))]]) on entry
c("shell", "quick", "radix")
Tracing eval(formal.args[[deparse(substitute(arg))]]) on entry
c("pearson", "kendall", "spearman")
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: r-devel-bounces at r-project.org [mailto:r-devel-bounces at r-project.org] On Behalf Of Paul Johnson
> Sent: Monday, October 10, 2011 8:31 AM
> To: Mark.Bravington at csiro.au; R Devel List
> Subject: Re: [Rd] "What Calls What" diagram. Flow Chart?
>
> On Sun, Oct 9, 2011 at 5:29 PM, <Mark.Bravington at csiro.au> wrote:
> > Hi Paul
> >
> > Have you tried
> >
> > mvbutils::foodweb( where=asNamespace( 'lavaan'))
> >
> > (assuming lavaan has a namespace, otherwise where='package:lavaan')?
> >
> > Sounds like it's what you're after--
> >
> > Mark
> >
> Thanks, Mark. The foodweb graph for lavaan is a bit overwhelming.
>
> The graph shows everything it finds that might be called any time, it
> doesn't help me trace the path of a specific user call to a particular
> function. So I'm not entirely sure it is doing what I hope for.
>
> While matching the graph against the source code, it seems to me some
> R language idioms can confuse/break the foodweb. When eval is called
> on a string object, then I think function calls can escape detection.
> In the cfa example code I put in the original post, the function
> "lavaan" is called by eval, and as far as I can tell in the foodweb
> output, that connection is not found.
>
> I'm still studying your package, of course, but here's (I think) an
> example, I know "cfa" does call "lavaan" though eval, but this code
>
> library(lavaan)
> library(mvbutils)
> mvbutils::foodweb( where=asNamespace( 'lavaan'))
>
> myfw <- mvbutils::foodweb( where=asNamespace( 'lavaan'))
>
> callers.of("lavaan", myfw)
>
>
> > [1] "independence.model" "independence.model.fit"
> [3] "independence.model.fit2" "setLavaanOptions"
>
>
>
>
> --
> Paul E. Johnson
> Professor, Political Science
> 1541 Lilac Lane, Room 504
> University of Kansas
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list