This project is read-only.

alternative to str() in source() to get full variable's output

Oct 7, 2015 at 4:24 PM
Edited Oct 7, 2015 at 4:31 PM
Hi all,

I'm able to start REngine in a .Net 4.5 Console Application in C#. Then I let a script running using source().
engine.Evaluate("source('" + rFile + "', local = " + env+ ")");
This works fine and I get some output on my console, e.g. when a package is loaded but I'd like to get some more output.

In the examples I only found str() to get some output on my console (not the R console and also not the R Studio console but the application console coming from Visual Studio). Using str() only gives me a short overview which is great at times but right now I'd like to see every entry of my variable. I want to get the full output of a variable, e.g. in R I would type the variable's name. However when I type just the variable's name in my R-file and source() this file from C# I don't get any output on my console application.

I can get the variables output with REnginge by
engine.Evaluate("with(" + env + ", variableName)");
Is there any simple way I get the variable's output from a R file that's being source()ed? I read about writing your own console ( but I think there might be an other way to just to display a variable, right?

Oct 9, 2015 at 10:35 PM
Edited Oct 9, 2015 at 10:42 PM
Interesting observation.

R.NET engine has AutoPrint set to true by default (matches R behavior). Testing something:
# c:/tmp/blah.r
danca <- 'kizomba'
featuring <- 'Saaphy'
danca # does not print if source-d , even if R.NET engine.AutoPrint == true
indeed print to the console only:
[1] "Saaphy"
Incidentaly it matches the behavior of an R terminal:
> source("c:/tmp/blah.r")
[1] "Saaphy"
So whether from R or R.NET you need to use print to get output. Or, in C#:
# you can query variable names in the global environment with:
The following test program may be of use:
Oct 10, 2015 at 3:06 PM