Re: [Rcom-l] More on Get R output and why does it echo so much in 1 pass?
> x <- 1:5 > y <- 6:10 > plot(x=x, y=y) > plot(y, x) > plot(x=y, y=x) > x [1] 1 2 3 4 5 > y [1] 6 7 8 9 10 > plot(x<-y, y<-x) > x [1] 6 7 8 9 10 > y [1] 6 7 8 9 10 > >From this example, you see that "=" and "<-" have different behaviors inside argument lists. Check the archives for other examples and discussion. RSiteSearch('What to use for assignment, " = " or " <- "?') brings up several threads including this post from Bill Venables http://finzi.psych.upenn.edu/R/Rhelp02a/archive/126700.html Rich ___ 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
Re: [Rcom-l] More on Get R output and why does it echo so much in 1 pass?
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 valuePr(>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 valuePr(>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
[Rcom-l] More on Get R output and why does it echo so much in 1 pass?
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 valuePr(>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 valuePr(>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