Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7804379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:53:39+00:00 2026-06-02T01:53:39+00:00

If I have a few interconnected functions, then it can be useful to trace

  • 0

If I have a few interconnected functions, then it can be useful to trace the path through them. That is using the trace function to give a message each time R enters or leaves one of the functions. For example,

f <- function() g()
g <- function() h()
h <- function()
{
 if(runif(1) > 0.3) g() else 99
}

trace_my_fns <- function()
{
  fn_names <- c("f", "g", "h")
  invisible(trace(
    fn_names,
    tracer = quote(0),
    exit   = quote(0),
    where  = globalenv()
  ))
}

trace_my_fns()
set.seed(4)
f()

When I’m finished with this tracing, I need to untrace them.

untrace_my_fns <- function()
{
  fn_names <- c("f", "g", "h")
  invisible(trace(
    fn_names,
    where = globalenv()
  ))
}
untrace_my_fns()

For some reason, this isn’t untracing the functions properly. To see this, take a look at

f
body(f)

If I directly call untrace on each function, for example untrace(f) at the commmand line, it works. How should I create a function to untrace all my functions at once?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:53:41+00:00Added an answer on June 2, 2026 at 1:53 am

    Well, change to:

    untrace_my_fns <- function()
    {
      fn_names <- c("f", "g", "h")
      invisible(untrace(
        fn_names,
        where = globalenv()
      ))
    }
    
    untrace_my_fns()
    set.seed(4)
    f() # no more tracing...
    

    …because you called trace instead of untrace!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have few thousand reports that have consistently formatted tabular data embedded within them that
I have few long commands that I will be using on a day to
I have few node types and some of them have an extra field is
I have few tabs and I need to way to access textboxes on them
I have few questions about using lock to protect my shared data structure. I
I have few 'so' files that I need to load in maven java project
I have few Vaadin tabs one of them is displaying an table and some
I have few databses of sql 2000 on windows 2000. Can I attach these
I have few values existing in data base,i need to update them but,i am
I have few TabPages and each contains rich text box. How can I access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.