We did not push you to use RExcel ;-)
You decided on your own.
If you should use it depends on what you want.
If you want the results of R computations in Excel,
and you want numbers to live in separate cells,
then you should probably use it.
With our copy and paste you get lines of text,
not numbers in cells.

RExcel has 5 demo workbooks showing what you can do.
They are available from the RExcel menu.
Have a look at these. They will show you what you can accomplish
with the connection mechanism.






On Oct 6, 2008, at 2:20 PM, D'Antuono, Mario wrote:

Many thanks to Richard Heiberger for his many comments and suggestions as well as Erich Neuwirth for their advice.I appreciate your time and effort in replying to my queries.

But I feel really confused as to why I would want to use REXCEL if I can just copy and paste my simple lines into the R console and get what I want?

ie this is the output from R console which I want  ...

eg1 <-  read.csv('eg1.csv',header=TRUE)
aov1 <- aov(yield~ factor(Treatment)+factor(Block),data=eg1)
anova(aov1)
Analysis of Variance Table
Response: yield
                 Df  Sum Sq Mean Sq F value    Pr(>F)
factor(Treatment)  3 10.7358  3.5786 112.026 1.173e-05 ***
factor(Block)      2  1.7150  0.8575  26.843  0.001016 **
Residuals          6  0.1917  0.0319
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Sorry for bieng so obstinate but I do not want to be an Excel VBA expert. I just would like to have a facility for my colleagues to run my few lines via RExcel with just the above output in 1 pass (not 2 or more?)? Is it really that hard to have a switch in RExcel to give me the above output?

Also Richard, I see that the Venables and Smith Introduction to R suggests an equal sign = (which i find easier to explain to non- statisticians who are used to Excel) should work and gives the same output as using the assign characters ( <- ). Looks easier to read too and type. Have I got it wrong?

The longer output from Get R output is which is too long especially if i had hundreds of records in my data file
eg1 <-  read.csv('eg1.csv',header=TRUE)      
  plot Block Treatment yield    
1     1     1         D   4.6   
2     2     1         A   7.3   
3     3     1         C   5.5   
4     4     1         B   6.3   
5     5     2         A   6.6   
6     6     2         C   5.4   
7     7     2         D   4.1   
8     8     2         B   5.9   
9     9     3         B   5.6   
10   10     3         D   3.5   
11   11     3         C   4.9   
12   12     3         A   6.0   
aov1 <- aov(yield~ factor(Treatment)+factor(Block),data=eg1) 
Call:   
aov(formula = yield ~ factor(Treatment) + factor(Block), data = eg1)
        
Terms:  
               factor(Treatment) factor(Block) Residuals        
Sum of Squares          10.735833      1.715000  0.191667       
Deg. of Freedom                 3             2         6       
        
Residual standard error: 0.1787301      
Estimated effects may be unbalanced     
anova(aov1)     
Analysis of Variance Table      
        
Response: yield 
                 Df  Sum Sq Mean Sq F value    Pr(>F)        
factor(Treatment)  3 10.7358  3.5786 112.026 1.173e-05 ***      
factor(Block)      2  1.7150  0.8575  26.843  0.001016 **       
Residuals          6  0.1917  0.0319                            
---     
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1  

Sorry for being so confused but is there any hope for me with RExcel to get what I want? It should be so easy I thought?

M.


Mario D'Antuono
Biometrics Unit
Department of Agriculture and Food
Government of Western Australia
------------------------------------------------
Address: 3 Baron-Hay Court, South Perth  WA  6151
Postal: Locked Bag 4, Bentley Delivery Centre  WA  6983
Telephone: (08) 9368 3848 International +61+8+9368 3848
Fax (08) 9368 2958
Mobile: 0400 576 764
http://www.agric.wa.gov.au/biometrics




________________________________

From: [EMAIL PROTECTED] on behalf of Richard M. Heiberger
Sent: Sun 05-Oct-08 12:28 PM
To: R(D)COM and RExcel server related issues
Subject: RE: [Rcom-l] Installing RExcel on a windowsmachine withExcel 2002(sp3)



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 <http://rcom.univie.ac.at/ >




This e-mail and files transmitted with it are privileged and confidential information intended for the use of the addressee. The confidentiality and/or privilege in this e-mail is not waived, lost or destroyed if it has been transmitted to you in error. If you received this
e-mail in error you must
(a) not disseminate, copy or take any action in reliance on it;
(b) please notify the Department of Agriculture and Food, WA immediately by return e-mail to the sender;
(c) please delete the original e-mail.

This email has been successfully scanned by
McAfee Anti-Virus software.
Department of Agriculture and Food WA
<winmail.dat>_______________________________________________
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

--
Erich Neuwirth
Didactic Center for Computer Science and Institute for Scientific Computing
University of Vienna




_______________________________________________
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