I figured out what Mario DAntuono did to get the behavior he is reporting.

The technical answer is that the right-click 'Run R' command eventually
runs the macro RMenuMacros.SendCommands which includes the line

        cmdString = 
"putRExcel("".rexcel.last.output"",capture.output(print(try({" & _
                    cmdString & "},silent=TRUE))))"

The print() function in that statement is giving the output that isn't wanted.

I think the solution is to use two different 'Run R' commands
instead of only one.  In your example, I would use one 'Run R'
command for the two lines

 setwd('C:/RxM/Examples/Roo') 
 eg1 = read.csv('eg1.csv',header=TRUE) 

and a separate 'Run R' for the line

 tmp.aov <- aov(A ~ C, data=tmp)

The 'Get R Output' would show only the printout from the
most recent 'Run R'.


Now, to duplicate the situation, we need 7 steps:

1. Create a file in your home directory, for example,
tmp.csv, containing 5 lines

A,B,C
1,2,a
4,5,b
7,8,c
10,11,d

2. In Excel, enter the three lines in cells A1:A3
getwd()
tmp <- read.csv("tmp.csv")
tmp.aov <- aov(A ~ C, data=tmp)

3. Highlight A1:A3 and right-click 'Run R'
4. right-click 'Get R Output' to
see the complete transcript of the three lines that were input
to the 'Run R' statement, including
the output from the two assignments that were wrapped in
the print() statement by the macro.  The output from the
second line is the output that is not wanted.

5. Highlight A1:A2 and right-click 'Run R'
6. Highlight A3 and right-click 'Run R'
7. right-click 'Get R Output' to
see the transcript from running the the one line in cell A3
that was run in the 'Run R' statement.
This is the output that is wanted.


Please note that I used " <- ", an assignment arrow surrounded
by spaces, for the assignments.  This is strongly preferred by
most R programmers over the "=" sign.  


_______________________________________________
Rcom-l mailing list
Rcom-l@mailman.csd.univie.ac.at
http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l
More information (including a Wiki) at http://rcom.univie.ac.at

Reply via email to