[R] Outputting variable names and their value bindings

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Mon Jun 25 01:38:30 CEST 2018

Yes [1], though most people use it interactively, e.g.


[1] https://cran.r-project.org/manuals.html

On June 24, 2018 4:31:40 PM PDT, Simon Ellis <sellis using vassar.edu> wrote:
>Thank you for your reply.
>At the moment, my colleague and her students are just using
>zero-dimensional variables for output, no vectors or matrices, which
>make my life easier.
>Since my code-glue parses through the scripts' code to substitute
>as required, I could code a command to cause my system to emit a line
>get R to print something I could use.
>I am sure this is a dumb question, but is there a reference manual for
>available online?
>On 24 June 2018 at 16:14, Jeff Newmiller <jdnewmil using dcn.davis.ca.us>
>> Yes and no. R does not have a "Matlab-output-compatibility" mode, but
>> can write your script to output anything you want it to using the
>> function with various functions like "sprintf" and "as.character".
>You may
>> want to write some functions that format some common objects that you
>> typically output. Then just make sure to use those functions instead
>of the
>> standard "put an object alone on a line" method of printing.
>> On June 24, 2018 11:00:51 AM PDT, Simon Ellis <sellis using vassar.edu>
>> >Hullo,
>> >
>> >I'm writing a piece of scripting glue for a colleague who is doing
>> >computations in several different languages. (It's the most
>> >way,
>> >right now.) My system calls the relevant program (e.g. Rstudio,
>> >with a path to a script, captures stdout and parses it for output
>> >variables, which it stores in its own environment for use later on.
>> >
>> >This is easy with MATLAB, since it writes back the variable name
>> >its
>> >value, e.g.:
>> >
>> >> freq = {somefunction}()
>> >freq =
>> >
>> >    <value>
>> >
>> >All I have to do is look for lines with '=' on the end, then grab
>> >next
>> >section of non-empty lines as the binding for the variable. Boom.
>> >
>> >With Rscript, if I write something like this:
>> >
>> >Rscript -e "a = (2 + 2)" -e "a"
>> >
>> >it prints
>> >
>> >[1] 4
>> >
>> >Is there any way to get R to print output similarly to MATLAB, in an
>> >= y
>> >format?
>> >
>> >I have other solutions in mind, but they're all kludgy and I'd
>> >not
>> >have to. Please can someone save me from the kludge? :-D
>> >
>> >Thank you,
>> >
>> >~Simon Ellis
>> --
>> Sent from my phone. Please excuse my brevity.

Sent from my phone. Please excuse my brevity.

More information about the R-help mailing list