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 6390831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:35:48+00:00 2026-05-25T03:35:48+00:00

This is crazy, and just out of intellectual curiosity: Can I run a function

  • 0

This is crazy, and just out of intellectual curiosity: Can I run a function in R in such a way that after the function completes I can get all variables created when the function executed? So the ability to look into a function right before it returned? I don’t mean entering the function in debug mode.

  • 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-05-25T03:35:48+00:00Added an answer on May 25, 2026 at 3:35 am

    I’m not sure if this is what you want, but maybe close.
    You can embed an arbitral expression in existing functions by trace:

    > trace(lm, exit = function().last_env <<- parent.frame())
    Tracing function "lm" in package "stats"
    [1] "lm"
    > lm(y~x, data.frame(x=1:10, y=10:1))
    Tracing lm(y ~ x, data.frame(x = 1:10, y = 10:1)) on exit 
    
    Call:
    lm(formula = y ~ x, data = data.frame(x = 1:10, y = 10:1))
    
    Coefficients:
    (Intercept)            x  
             11           -1  
    
    > ls(.last_env)
     [1] "cl"          "contrasts"   "data"        "formula"     "m"           "method"      "mf"          "model"       "mt"          "na.action"   "offset"     
    [12] "qr"          "ret.x"       "ret.y"       "singular.ok" "subset"      "w"           "weights"     "x"           "y"           "z"          
    > get("cl", .last_env)
    lm(formula = y ~ x, data = data.frame(x = 1:10, y = 10:1))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is driving me crazy, I just can't find out the problem: I have
This may be way out in left field, crazy, but I just need to
This seems like it should work, but I just can't seem to figure out
After watching Martin's keynote on Reflection and Compilers I can't seem to get this
Maybe it is just a simple mistake but this thing is driving me crazy.
i have this crazy label for each time i create a migration that use
This is crazy, I have been trying for hours to get this to work.
I'm getting crazy with this IE 7... ==> hhttp://neu.emergent-innovation.com/ Why does following function not
This may seem a bit crazy, but if you can tell me a better
I just need a sanity check here... DEMO Basically, I can't figure out how

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.