0

I'm working through an R tutorial. Currently I'm writing a script that, in it's current format I know is incorrect.

I'd like to "see" the variables I've created within the function within the console so that I can learn about them. I know that writing global variables is discouraged.

So if I have a function foo and within foo is a variable called someVar is there a way, once I've loaded in the script with the function to, for example go like this:

str(foo.someVar) or str(foo(somevar)) ?

Doug Fir
  • 19,971
  • 47
  • 169
  • 299

1 Answers1

2

No, but if you want to walk through a function, you can use debugonce(functioname) before calling a function to break into a debugger when a function is called and you can then view variables internal to the function inside the debugger.

See here for more debugging tools in R.

Community
  • 1
  • 1
merlin2011
  • 71,677
  • 44
  • 195
  • 329