Re: [R] problem with looping formula through table

2011-03-14 Thread Scott Chamberlain
library(tseries) sie - get.hist.quote(instrument=SIE.DE, start=2010-01-01, quote=AdjClose) vow - get.hist.quote(instrument=VOW.DE, start=2010-01-01, quote=AdjClose) lin - get.hist.quote(instrument=LIN.DE, start=2010-01-01, quote=AdjClose) dax - get.hist.quote(instrument=^GDAXI, start=2010-01-01,

[R] problem with looping formula through table

2011-03-13 Thread herr dittmann
Dear useRs, I am stuck with a piece of code and hope you could give me some pointers. My aim is to calculate the lm-regression coefficients of individual stocks against an index. I am interested in both the coefficient and the pval. While I could do this manually for a select hand full, I hope

Re: [R] problem with looping on sqlSave()

2010-02-25 Thread Ivan Calandra
Hi! I've tried it, but the problem is that each element has a different size, with makes rbind() useless. Is there then a function/package that allows appending data in an Excel sheet? I've searched already for a few packages, but none (except, in theory, RODBC) can append. Any suggestion?

Re: [R] problem with looping on sqlSave()

2010-02-25 Thread Dieter Menne
Ivan Calandra wrote: I've tried it, but the problem is that each element has a different size, with makes rbind() useless. Assuming that size means different number of columns, then appending is not valid, because it would change the structure of the table, and with ODBC we are in the

Re: [R] problem with looping on sqlSave()

2010-02-25 Thread Ivan Calandra
What if size means both columns and rows? Here is one of such lists: test - structure(list(m = structure(c(0.090909090909091, 0.181818181818182, 0.272727272727273, 0.363636363636364, 0.454545454545455, 0.545454545454545, 0.636363636363636, 0.727272727272727, 0.818181818181818,

Re: [R] problem with looping on sqlSave()

2010-02-25 Thread Dieter Menne
Ivan Calandra wrote: What if size means both columns and rows? Then you are not longer in the database world, and should use one of the half dozen other methods to write to Excel, either native, via Perl (portable) or RCOM. Search R-search for write Excel. Dieter -- View this message

Re: [R] problem with looping on sqlSave()

2010-02-25 Thread Ivan Calandra
As I said earlier, none of the packages I have found (dataframes2xls, WriteXLS, xlsReadWrite, xlsx) to export to xls allow appending on the same sheet. So at the end, write.csv() is more flexible for my use. Do you know if the RExcel add-on would be useful in my case? I took a look at the

Re: [R] problem with looping on sqlSave()

2010-02-25 Thread Dieter Menne
Ivan Calandra wrote: As I said earlier, none of the packages I have found (dataframes2xls, WriteXLS, xlsReadWrite, xlsx) to export to xls allow appending on the same sheet. Please check again. WriteXLS has a parameter where to start writing. D -- View this message in context:

Re: [R] problem with looping on sqlSave()

2010-02-25 Thread Ivan Calandra
I've checked in the package WriteXLS and couldn't find such parameter (I hope I didn't overlook anything!). However write.xls() in xlsReadWrite package has such parameter. I've tried it and the problem is that, even though I can make the writing start at the last line, it will overwrite the

Re: [R] problem with looping on sqlSave()

2010-02-25 Thread Marc Schwartz
Just to confirm, WriteXLS() does not have such a parameter, but write.xls() in the xlsReadWRite package does. As you have noted however, none of these approaches are really designed to enable flexible appending to an existing Excel file. As I believe Dieter noted in an earlier post, your best

[R] problem with looping on sqlSave()

2010-02-24 Thread Ivan Calandra
Dear R users, I have a follow-up question on sqlSave(). Since most of the output from the tests I use are lists, I would like to loop to export each element of the list and append it to the sheet. Here is what I do: library(RODBC) test - structure(list(m = structure(c(0.090909090909091,

Re: [R] problem with looping on sqlSave()

2010-02-24 Thread Dieter Menne
Ivan Calandra wrote: ... for (i in 1:4){ sqlSave(xlsFile, as.data.frame(test[[i]]), tablename=test, rownames=F, addPK=T, append=T) } Error in odbcUpdate(channel, query, mydata, coldata[m, ], test = test, : missing columns in 'data' odbcCloseAll() I have never managed to

[R] :Problem with Looping

2009-11-17 Thread Bruno Giovannetti
Hello, Sometimes the looping (using for) seems to skip some iterations. An example: arg - matrix(NA,length(seq(.30,.5,.01)),1) for (i in seq(.30,.5,.01)) { arg[i*100-29] - i } arg What is the problem with this coding, please? Thank you so much, -- Bruno Cara Giovannetti, PhD Candidate

Re: [R] :Problem with Looping

2009-11-17 Thread Benilton Carvalho
it doesn't skip... think about why: seq(.30,.5,.01) * 100 - 29 == 1:21 isn't always TRUE. b On Nov 17, 2009, at 9:17 PM, Bruno Giovannetti wrote: Hello, Sometimes the looping (using for) seems to skip some iterations. An example: arg - matrix(NA,length(seq(.30,.5,.01)),1) for (i in

Re: [R] :Problem with Looping

2009-11-17 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bruno Giovannetti Sent: Tuesday, November 17, 2009 3:18 PM To: r-help@r-project.org Subject: [R] :Problem with Looping Hello, Sometimes the looping (using for) seems to skip