Re: [R] Rcmdr GUI goes into loop via alt+backspace under Windows OS

2009-07-22 Thread tradenet

Robert,

Alt+Backspace is a standard global shortcut key shortcut key for most
Windows programs (Word, Excel, Visual Studio, Notepad, Wordpad.  It is
equivalent to Ctrl+Z

It has been around since at least windows 98:
http://www.microsoft.com/enable/products/KeyboardSearch_98.aspx

I wished alt+backspace performed the same action under Vista x64, or rang a
bell like it does on your machine.

Thanks for the feedback.

Regards,


Andrew



Robert Baer wrote:
 
 It just produces the bell sound on my 32-bit windows XP machine runing R 
 2.9.1
 
 Is this really a standard combination?  I know a  lot of programs that
 use 
 ctrl-Z, but I've never come across this shortcut key combination for undo.
 
 
 - Original Message - 
 From: tradenet nodeco...@yahoo.com
 To: r-help@r-project.org
 Sent: Tuesday, July 21, 2009 5:39 PM
 Subject: [R] Rcmdr GUI goes into loop via alt+backspace under Windows OS
 
 

 I'm using Rcmdr version 1.4-10 with R version 2.9.0 under Vista x64.

 A standard editing convention under Windows is that alt+backspace is a
 keyboard shortcut for undo.  I often find myself hitting the [alt] and
 [backspace] keys while editing scripts in Rcmdr. However, this causes the
 Rcmdr GUI to go into a crazy mode where the menu keeps flashing and the 
 GUI
 is unresponsive.  Sometimes after several minutes, the GUI menus stop
 sporadically flashing and the GUI becomes responsive again, but usually I
 have to kill R.

 Has anyone else seen this problem and might there be a fix for it?

 If it weren't for the fact that the particular key combination is a 
 standard
 in Windows I would ignore the problem, but I often get trapped by it 
 because
 the GUI handles this standard Windows key combination is such a bizzare 
 way.

 I'd appreciate any suggestions you might have.

 Regards,

 Andrew
 -- 
 View this message in context: 
 http://www.nabble.com/Rcmdr-GUI-goes-into-loop-via-alt%2Bbackspace-under-Windows-OS-tp24597087p24597087.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Rcmdr-GUI-goes-into-loop-via-alt%2Bbackspace-under-Windows-OS-tp24597087p24609888.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Rcmdr GUI goes into loop via alt+backspace under Windows OS

2009-07-21 Thread tradenet

I'm using Rcmdr version 1.4-10 with R version 2.9.0 under Vista x64.

A standard editing convention under Windows is that alt+backspace is a
keyboard shortcut for undo.  I often find myself hitting the [alt] and
[backspace] keys while editing scripts in Rcmdr. However, this causes the
Rcmdr GUI to go into a crazy mode where the menu keeps flashing and the GUI
is unresponsive.  Sometimes after several minutes, the GUI menus stop
sporadically flashing and the GUI becomes responsive again, but usually I
have to kill R.

Has anyone else seen this problem and might there be a fix for it?

If it weren't for the fact that the particular key combination is a standard
in Windows I would ignore the problem, but I often get trapped by it because
the GUI handles this standard Windows key combination is such a bizzare way.

I'd appreciate any suggestions you might have.

Regards,

Andrew
-- 
View this message in context: 
http://www.nabble.com/Rcmdr-GUI-goes-into-loop-via-alt%2Bbackspace-under-Windows-OS-tp24597087p24597087.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] RODBC results from stored procedure

2009-07-21 Thread tradenet

Thanks Dieter.

The stored proc drops and recreates a result table that contains a copy of
the same result set that is returned by the query.

If I pause after line 1, line 2 returns a valid result set and line 4
displays a table of data.
If I do not pause the script after line 1 or 2, line 3 fails, saying
datatable does not exist (line 1 query has not completed the recreation of
datatable) and line 4 displays no data.

Also, the query in line one returns a single result set, a select statement
from datatable, but R doesn't see this returned result set after invocation
of only line 1. 


1.) dbdata-sqlQuery(conn,sp_GetData)  #returns a result set in query
analyzer, not in R
2.) head(dbdata) #it's empty
3.) dbdata-sqlQuery(conn,select * from datatable order by Date asc) 
4.) head(dbdata) #the data is in dbdata


My workaround is to run line 1's query manually before running any R
scripts.  Not ideal, but I'm at a loss for what else to try for this prickly
case.

Warm regards,

Andrew




Dieter Menne wrote:
 
 
 
 tradenet wrote:
 
 Thanks Dieter.
 
 The date argument isn't a problem.  When I invoke the stored proc
 execution with the date arguments the stored proc runs fine, but RODBC
 doesn't wait for the stored proc to finish and return results.
 
 
 
 Don't understand that one. How do you know that is did not wait to finish? 
 
 Did the call I showed you work with the Northwind database?
 
 Dieter
 
 

-- 
View this message in context: 
http://www.nabble.com/RODBC-results-from-stored-procedure-tp24503096p24597208.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] RODBC results from stored procedure

2009-07-20 Thread tradenet

Thanks Dieter.

The date argument isn't a problem.  When I invoke the stored proc execution
with the date arguments the stored proc runs fine, but RODBC doesn't wait
for the stored proc to finish and return results.

Regards,

Andrew


Dieter Menne wrote:
 
 
 
 tradenet wrote:
 
 Short of uploading a SQL server database, I don't think I can make this
 example reproducible, but I hope it's not so complicated as to require
 reproducibility
 
 I can call a parametrized stored procedure without a problem and the proc
 does indeed execute successfully. 
 
 
 This works for me with the popular Northwind database
 
 channel = odbcConnect(northwind) # Assume this is configured correctly
 sqlQuery(channel,EXEC CustOrderHist @CustomerID=ALFKI)
 
 Try with a non-date query first, the switch to the tricky date format in
 the parameter.
 
 Dieter
 
 
 

-- 
View this message in context: 
http://www.nabble.com/RODBC-results-from-stored-procedure-tp24503096p24576806.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] RODBC results from stored procedure

2009-07-15 Thread tradenet

Short of uploading a SQL server database, I don't think I can make this
example reproducible, but I hope it's not so complicated as to require
reproducibility

I'm using RODBC to get data from Microsoft SQL Server.
I can call a parametrized stored procedure without a problem and the proc
does indeed execute successfully.  However, even though the proc returns the
results I found that I had to modify the proc so that, in addition to
returning the results to the caller, it also saved the results to an actual
SQL Server table.  Then I was able to make second call to sqlQuery with a
simple select statement for the results table and retrieve the results back
into R.  My question is:  can I get stored proc results directly back to R
without having to populate and query a results table?


dbdata-sqlQuery(conn,sp_GetReturns,'2009-07-10','2009-07-14')
head(dbdata)
character(0)  [no data here]
dbdata-sqlQuery(conn,select * from returns order by Date asc) 
[...success...]

  Date  Asset1   Asset2
2009-07-10  0.010.02
2009-07-13  0.007  -0.003
...

I'd appreciate any suggestions,

Andrew

W






rm(dbdata)


#run query in query analyzer and get date from rtnsUnderscored table
#dbdata-sqlFetch(conn,sqtable=sp_GetModelRtns4OptimizeRangeVer4
5000,'2001-10-01','2009-07-14)
#dbdata-sqlFetch(conn,sqtable=sp_GetModelRtns4OptimizeRangeVer4
5000,'2009-07-01','2009-07-14)

dbdata-sqlQuery(conn,select * from rtnsUnderscored order by Date asc)
-- 
View this message in context: 
http://www.nabble.com/RODBC-results-from-stored-procedure-tp24503096p24503096.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] getting a timeseries element into a string

2009-07-13 Thread tradenet

Thanks Ron.

I apologize for not properly specifying which class/package I was using.  I
am using the timeSeries class from the timeSeries Package, version 2100.83
from rmetrics.org

The code you supplied works for me! -- thanks again.

Warm regards,

Andrew


--

Ron Burns-2 wrote:
 
 Here is what I do:
 
 R library(fBasics)
 R ts-dummyDailySeries(x = rnorm(365), units = NULL, zone = , 
 FinCenter =)
 R class(ts)
 [1] timeSeries
 attr(,package)
 [1] timeSeries
 R (s - as.character(time(ts)[1]))
 [1] 1970-01-01
 R class(s)
 [1] character
 
 
 
 
 
 
 tradenet wrote:
 I added a reproducible example to my question...

 ts-dummyDailySeries(x = rnorm(365), units = NULL, zone = , FinCenter =
 )

   
 (ts[1,0])  #returns first date in return series
 
 GMT

 1970-01-01

   
 ttt-(sprintf(%s,ts[1,0]))
 

   
 print(ttt)
 
 character(0)

   
 ttt-(ts[1,0])
 

   
 print(ttt)
 
 GMT

 1970-01-01

 what I want to get is a string containing 1970-01-01

 Thank you.







 tradenet wrote:
   
 I have a timeseries object, ts, and want to get the first date in the
 series into a string so I can concatenate it with a SQL query. Input and
 output are shown below.  I must be missing something very basic, but I
 can't seem to pry the data (2008-07-01) into a string variable.  Any
 suggestions would be appreciated.

 Thank you,

 Andrew

 =script:
 class(ts)
 (ts[1,0])  #returns first date in return series
 ttt-(sprintf(%s,ts[1,0]))
 print(ttt)

 =output:


 
 class(ts)
   
 [1] timeSeries
 attr(,package)
 [1] timeSeries

 
 (ts[1,0])  #returns first date in return series
   
 GMT

 2008-07-01

 
 ttt-(sprintf(%s,ts[1,0]))
   
 print(ttt)
   
 character(0)




 

   
 
 
 -- 
 R. R. Burns
 Physicist (Retired)
 Oceanside, CA
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/getting-a-timeseries-element-into-a-string-tp24429876p24465343.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] getting a timeseries element into a string

2009-07-12 Thread tradenet

I added a reproducible example to my question...

ts-dummyDailySeries(x = rnorm(365), units = NULL, zone = , FinCenter =
)

 (ts[1,0])  #returns first date in return series
GMT

1970-01-01

 ttt-(sprintf(%s,ts[1,0]))

 print(ttt)
character(0)

 ttt-(ts[1,0])

 print(ttt)
GMT

1970-01-01

what I want to get is a string containing 1970-01-01

Thank you.







tradenet wrote:
 
 I have a timeseries object, ts, and want to get the first date in the
 series into a string so I can concatenate it with a SQL query. Input and
 output are shown below.  I must be missing something very basic, but I
 can't seem to pry the data (2008-07-01) into a string variable.  Any
 suggestions would be appreciated.
 
 Thank you,
 
 Andrew
 
 =script:
 class(ts)
 (ts[1,0])  #returns first date in return series
 ttt-(sprintf(%s,ts[1,0]))
 print(ttt)
 
 =output:
 
 
 class(ts)
 [1] timeSeries
 attr(,package)
 [1] timeSeries
 
 (ts[1,0])  #returns first date in return series
 GMT
 
 2008-07-01
 
 ttt-(sprintf(%s,ts[1,0]))
 
 print(ttt)
 character(0)
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/getting-a-timeseries-element-into-a-string-tp24429876p24448064.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] strange strsplit gsub problem 0 is this a bug or a string length limitation?

2009-07-10 Thread tradenet

I was working with the rmetrics portfolioBacktesting function and dug into
the code to try to find why my formula with 113 items, i.e. A1 thru A113,
was being truncated and I only get 85 items, not 113.

Is it due to a string length limitation in R or is it a bug in the strsplit
or gsub functions, or in my string?

I'd very much appreciate any suggestions


Input script:

backtestFormula-SPX~A1+A2+A3+A4+A5+A6+A7+A8+A9+A10+A11+A12+A13+A14+A15+A16+A17+A18+A19+A20+A21+A22+A23+A24+A25+A26+A27+A28+A29+A30+A31+A32+A33+A34+A35+A36+A37+A38+A39+A40+A41+A42+A43+A44+A45+A46+A47+A48+A49+A50+A51+A52+A53+A54+A55+A56+A57+A58+A59+A60+A61+A62+A63+A64+A65+A66+A67+A68+A69+A70+A71+A72+A73+A74+A75+A76+A77+A78+A79+A80+A81+A82+A83+A84+A85+A86+A87+A88+A89+A90+A91+A92+A93+A94+A95+A96+A97+A98+A99+A100+A101+A102+A103+A104+A105+A106+A107+A108+A109+A110+A111+A112+A113
benchmarkName = as.character(backtestFormula)[2]
print(as.character(backtestFormula)[3])
print(benchmarkName)
assetsNames - strsplit(gsub( , , as.character(backtestFormula)[3]),
\\+)[[1]]
nAssets = length(assetsNames)
print(nAssets)
list(assetsNames)

===output:


 backtestFormula-SPX~A1+A2+A3+A4+A5+A6+A7+A8+A9+A10+A11+A12+A13+A14+A15+A16+A17+A18+A19+A20+A21+A22+A23+A24+A25+A26+A27+A28+A29+A30+A31+A32+A33+A34+A35+A36+A37+A38+A39+A40+A41+A42+A43+A44+A45+A46+A47+A48+A49+A50+A51+A52+A53+A54+A55+A56+A57+A58+A59+A60+A61+A62+A63+A64+A65+A66+A67+A68+A69+A70+A71+A72+A73+A74+A75+A76+A77+A78+A79+A80+A81+A82+A83+A84+A85+A86+A87+A88+A89+A90+A91+A92+A93+A94+A95+A96+A97+A98+A99+A100+A101+A102+A103+A104+A105+A106+A107+A108+A109+A110+A111+A112+A113

 benchmarkName = as.character(backtestFormula)[2]

 print(benchmarkName)
[1] SPX

 print(as.character(backtestFormula)[3])
[1] A1 + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9 + A10 + A11 + A12 + A13 +
A14 + A15 + A16 + A17 + A18 + A19 + A20 + A21 + A22 + A23 + A24 + A25 + A26
+ A27 + A28 + A29 + A30 + A31 + A32 + A33 + A34 + A35 + A36 + A37 + A38 +
A39 + A40 + A41 + A42 + A43 + A44 + A45 + A46 + A47 + A48 + A49 + A50 + A51
+ A52 + A53 + A54 + A55 + A56 + A57 + A58 + A59 + A60 + A61 + A62 + A63 +
A64 + A65 + A66 + A67 + A68 + A69 + A70 + A71 + A72 + A73 + A74 + A75 + A76
+ A77 + A78 + A79 + A80 + A81 + A82 + A83 + A84 + A85 + 

 assetsNames - strsplit(gsub( , , as.character(backtestFormula)[3]),
 \\+)[[1]]

 print(nAssets)
[1] 85

 nAssets = length(assetsNames)

 print(nAssets)
[1] 85

 list(assetsNames)
[[1]]
 [1] A1  A2  A3  A4  A5  A6  A7  A8  A9  A10 A11 A12
A13 A14 A15 A16 A17 A18 A19 A20 A21 A22 A23 A24
A25 A26 A27 A28 A29 A30 A31 A32 A33
[34] A34 A35 A36 A37 A38 A39 A40 A41 A42 A43 A44 A45
A46 A47 A48 A49 A50 A51 A52 A53 A54 A55 A56 A57
A58 A59 A60 A61 A62 A63 A64 A65 A66
[67] A67 A68 A69 A70 A71 A72 A73 A74 A75 A76 A77 A78
A79 A80 A81 A82 A83 A84 A85



-- 
View this message in context: 
http://www.nabble.com/strange-strsplit-gsub-problem-0-is-this-a-bug-or-a-string-length-limitation--tp24426457p24426457.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] strange strsplit gsub problem 0 is this a bug or a string length limitation?

2009-07-10 Thread tradenet

Thanks Marc!

I just found that the ~500 char limitation via an online search for the
specs for the formula class
The rmetrics library I'm using get's it's character array of assets by
parsing a formula passed as an input parameter to the portfolioBacktest
function.  Can I copy the portfolioBacktest function from the source, call
it portfolioBackest_hack, add an additional pamater, an array of asset
names, and have my version use this argument instead of parsing the formula? 
I'm fairly new to R so I don't know if R will find my function and if my
function will find the other fPortfolio functions that may be referenced by
the original, non _hack version of the function.

Warm regards,

Andrew


Marc Schwartz-3 wrote:
 
 On Jul 10, 2009, at 7:18 AM, tradenet wrote:
 

 I was working with the rmetrics portfolioBacktesting function and  
 dug into
 the code to try to find why my formula with 113 items, i.e. A1 thru  
 A113,
 was being truncated and I only get 85 items, not 113.

 Is it due to a string length limitation in R or is it a bug in the  
 strsplit
 or gsub functions, or in my string?

 I'd very much appreciate any suggestions


 Input script:

 backtestFormula- 
 SPX~A1+A2+A3+A4+A5+A6+A7+A8+A9+A10+A11+A12+A13+A14+A15+A16+A17+A18+A19+A20+A21+A22+A23+A24+A25+A26+A27+A28+A29+A30+A31+A32+A33+A34+A35+A36+A37+A38+A39+A40+A41+A42+A43+A44+A45+A46+A47+A48+A49+A50+A51+A52+A53+A54+A55+A56+A57+A58+A59+A60+A61+A62+A63+A64+A65+A66+A67+A68+A69+A70+A71+A72+A73+A74+A75+A76+A77+A78+A79+A80+A81+A82+A83+A84+A85+A86+A87+A88+A89+A90+A91+A92+A93+A94+A95+A96+A97+A98+A99+A100+A101+A102+A103+A104+A105+A106+A107+A108+A109+A110+A111+A112+A113
 benchmarkName = as.character(backtestFormula)[2]
 print(as.character(backtestFormula)[3])
 print(benchmarkName)
assetsNames - strsplit(gsub( , ,  
 as.character(backtestFormula)[3]),
 \\+)[[1]]
nAssets = length(assetsNames)
 print(nAssets)
 list(assetsNames)

 ===output:


 backtestFormula- 
 SPX~A1+A2+A3+A4+A5+A6+A7+A8+A9+A10+A11+A12+A13+A14+A15+A16+A17+A18+A19+A20+A21+A22+A23+A24+A25+A26+A27+A28+A29+A30+A31+A32+A33+A34+A35+A36+A37+A38+A39+A40+A41+A42+A43+A44+A45+A46+A47+A48+A49+A50+A51+A52+A53+A54+A55+A56+A57+A58+A59+A60+A61+A62+A63+A64+A65+A66+A67+A68+A69+A70+A71+A72+A73+A74+A75+A76+A77+A78+A79+A80+A81+A82+A83+A84+A85+A86+A87+A88+A89+A90+A91+A92+A93+A94+A95+A96+A97+A98+A99+A100+A101+A102+A103+A104+A105+A106+A107+A108+A109+A110+A111+A112+A113

 benchmarkName = as.character(backtestFormula)[2]

 print(benchmarkName)
 [1] SPX

 print(as.character(backtestFormula)[3])
 [1] A1 + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9 + A10 + A11 + A12 +  
 A13 +
 A14 + A15 + A16 + A17 + A18 + A19 + A20 + A21 + A22 + A23 + A24 +  
 A25 + A26
 + A27 + A28 + A29 + A30 + A31 + A32 + A33 + A34 + A35 + A36 + A37 +  
 A38 +
 A39 + A40 + A41 + A42 + A43 + A44 + A45 + A46 + A47 + A48 + A49 +  
 A50 + A51
 + A52 + A53 + A54 + A55 + A56 + A57 + A58 + A59 + A60 + A61 + A62 +  
 A63 +
 A64 + A65 + A66 + A67 + A68 + A69 + A70 + A71 + A72 + A73 + A74 +  
 A75 + A76
 + A77 + A78 + A79 + A80 + A81 + A82 + A83 + A84 + A85 + 

 assetsNames - strsplit(gsub( , , as.character(backtestFormula) 
 [3]),
 \\+)[[1]]

 print(nAssets)
 [1] 85

 nAssets = length(assetsNames)

 print(nAssets)
 [1] 85

 list(assetsNames)
 [[1]]
 [1] A1  A2  A3  A4  A5  A6  A7  A8  A9  A10  
 A11 A12
 A13 A14 A15 A16 A17 A18 A19 A20 A21 A22 A23  
 A24
 A25 A26 A27 A28 A29 A30 A31 A32 A33
 [34] A34 A35 A36 A37 A38 A39 A40 A41 A42 A43  
 A44 A45
 A46 A47 A48 A49 A50 A51 A52 A53 A54 A55 A56  
 A57
 A58 A59 A60 A61 A62 A63 A64 A65 A66
 [67] A67 A68 A69 A70 A71 A72 A73 A74 A75 A76  
 A77 A78
 A79 A80 A81 A82 A83 A84 A85
 
 
 
 You appear to be bumping up against the 500 character length limit of  
 as.character() when used with R language objects.
 
 Review the Note in ?as.character:
 
as.character truncates components of language objects to 500  
 characters (was about 70 before 1.3.1).
 
 
 
 It is not a string length limitation or a bug in strsplit():
 
   paste(A, 1:113, sep = , collapse =  + )
 [1] A1 + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9 + A10 + A11 + A12 +  
 A13 + A14 + A15 + A16 + A17 + A18 + A19 + A20 + A21 + A22 + A23 + A24  
 + A25 + A26 + A27 + A28 + A29 + A30 + A31 + A32 + A33 + A34 + A35 +  
 A36 + A37 + A38 + A39 + A40 + A41 + A42 + A43 + A44 + A45 + A46 + A47  
 + A48 + A49 + A50 + A51 + A52 + A53 + A54 + A55 + A56 + A57 + A58 +  
 A59 + A60 + A61 + A62 + A63 + A64 + A65 + A66 + A67 + A68 + A69 + A70  
 + A71 + A72 + A73 + A74 + A75 + A76 + A77 + A78 + A79 + A80 + A81 +  
 A82 + A83 + A84 + A85 + A86 + A87 + A88 + A89 + A90 + A91 + A92 + A93  
 + A94 + A95 + A96 + A97 + A98 + A99 + A100 + A101 + A102 + A103 + A104  
 + A105 + A106 + A107 + A108 + A109 + A110 + A111 + A112 + A113
 
 
   nchar(paste(A, 1:113, sep = , collapse =  + ))
 [1] 680
 
 
   strsplit(paste(A, 1:113, sep = , collapse =  + ),  \\+ )[[1]]
[1] A1   A2   A3   A4   A5   A6   A7   A8   A9
   [10] A10  A11  A12  A13  A14  A15  A16  A17

Re: [R] strange strsplit gsub problem 0 is this a bug or a string length limitation?

2009-07-10 Thread tradenet

Thanks Marc.

I forwarded the suggestion to Dr. Wuertz and Dr. Chalabi at Rmetrics.

Warm regards,

Andrew Borden



Marc Schwartz-3 wrote:
 
 On Jul 10, 2009, at 9:07 AM, tradenet wrote:
 

 Thanks Marc!

 I just found that the ~500 char limitation via an online search for  
 the
 specs for the formula class
 The rmetrics library I'm using get's it's character array of assets by
 parsing a formula passed as an input parameter to the  
 portfolioBacktest
 function.  Can I copy the portfolioBacktest function from the  
 source, call
 it portfolioBackest_hack, add an additional pamater, an array of asset
 names, and have my version use this argument instead of parsing the  
 formula?
 I'm fairly new to R so I don't know if R will find my function and  
 if my
 function will find the other fPortfolio functions that may be  
 referenced by
 the original, non _hack version of the function.

 Warm regards,

 Andrew
 
 Hi Andrew,
 
 Happy to help.
 
 In terms of your proposal as a short term fix, it may be possible to  
 do that. If you do create a new local function and call it directly,  
 it will be seen instead of the package default version of the same  
 function. However, without reviewing the code and package in detail,  
 you have to be careful about other function dependencies and namespace  
 issues that may be present.  I would go ahead and try it to see it it  
 works.
 
 A better and longer term approach would be to have the function  
 author(s) modify the way in which they manipulate the formula object.  
 They may wish to review this thread from 2001:
 
https://stat.ethz.ch/pipermail/r-help/2001-August/014628.html
 
 Back then, the as.character() limit was 60 and was increased by Prof.  
 Ripley to 500 in response to that discussion.
 
 However, in that thread, Prof. Ripley also proposes a better way of  
 manipulating the formula object passed to the function. That approach  
 uses deparse() rather than using as.character().
 
 HTH,
 
 Marc Schwartz
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/strange-strsplit-gsub-problem-0-is-this-a-bug-or-a-string-length-limitation--tp24426457p24429282.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] getting a timeseries element into a string

2009-07-10 Thread tradenet

I have a timeseries object, ts, and want to get the first date in the series
into a string so I can concatenate it with a SQL query. Input and output are
shown below.  I must be missing something very basic, but I can't seem to
pry the data (2008-07-01) into a string variable.  Any suggestions would
be appreciated.

Thank you,

Andrew

=script:
class(ts)
(ts[1,0])  #returns first date in return series
ttt-(sprintf(%s,ts[1,0]))
print(ttt)

=output:


 class(ts)
[1] timeSeries
attr(,package)
[1] timeSeries

 (ts[1,0])  #returns first date in return series
GMT

2008-07-01

 ttt-(sprintf(%s,ts[1,0]))

 print(ttt)
character(0)



-- 
View this message in context: 
http://www.nabble.com/getting-a-timeseries-element-into-a-string-tp24429876p24429876.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.