Re: [R] matching elements from two vectors

2007-08-17 Thread davidr
x %in% y David L. Reiner Rho Trading Securities, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gonçalo Ferraz Sent: Friday, August 17, 2007 9:46 AM To: r-help@stat.math.ethz.ch Subject: [R] matching elements from two vectors Hi, Imagine a vector

RE: [R] Null space (or kernel) and image of a matrix

2005-05-31 Thread davidr
help.search("null space") gives Null(MASS) Null Spaces of Matrices PLEASE PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html David Reiner Rho Trading Securities, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]

RE: [R] How to plot more than 3 sets in Venn Diagrams?

2005-06-09 Thread davidr
Here is a link to see what's possible. http://www.combinatorics.org/Surveys/ds5/VennSymmEJC.html Venn did 4 sets with ellipses (see wikipedia.) (There was an article in the last year (I think) in one of my math journals that presented someone who made these complex Venn diagrams as artwork and s

Re: [R] x*x*x*... vs x^n

2005-06-29 Thread davidr
In general, the "Russian peasant algorithm", which requires only O(log n) multiplications, is very good. Section 4.6.3 of Knuth's The Art of Computer Programming. Volume 2: Seminumerical Algorithms has an in depth discussion. I have had to use this in the past, when computers were slower and compil

Re: [R] x*x*x*... vs x^n

2005-06-29 Thread davidr
Looking at the code for gsl_pow_int, I see they do use that method. David L. Reiner > -Original Message- > From: [EMAIL PROTECTED] [mailto:r-help- > [EMAIL PROTECTED] On Behalf Of David Reiner > <[EMAIL PROTECTED]> > Sent: Wednesday, June 29, 2005 9:50 AM > To: r-help > Subject: Re: [R]

Re: [R] moving correlation coef ?

2005-06-29 Thread davidr
One common weighting scheme is exponentially weighted, i.e., wt = L^(0:m) , where 0 < L <= 1 . David L. Reiner p.s. If your question is coming from a financial application, you might be interested in the R-sig-finance list, as well as reading the RiskMetrics (r) document "Return to RiskMetrics:

Re: [R] x*x*x*... vs x^n

2005-06-29 Thread davidr
I was surprised to find that I was wrong about powers of complexes: > seq.pow1 <- function(x,n) { + y <- rep(x,n) + for(i in 2:n) y[i] <- y[i-1] * x + y + } > seq.pow2 <- function(x,n) x^(1:n) > x <- 1.001 + 1i * 0.999 # several reps of the following > system.time(ignore <- seq.pow1(x,10

[R] pretty for date-time?

2005-07-06 Thread davidr
pretty() works well for numbers and axTicks() can help for potting log axes, but has anyone written a pretty for chron objects (or other date or date-time classes)? It would have natural units of years, months, .., days, hours, (minutes?), and it would choose the appropriate unit based on the dat

Re: [R] Orthogonal regression

2005-07-08 Thread davidr
This topic has come up a few times recently, so it must be 'in the wind' these days. Depending on what approach you take and what area you are coming from, it goes under the names Orthogonal [Distance] Regression, Total Least Squares, Errors in Variables, Deming Regression. The middle two encomp

Re: [R] R: to the power

2005-07-12 Thread davidr
In general, x^y is evaluated as exp(y*log(x)). In your case, x is negative, so log(x) is NaN. Note also that 1/3 is not represented exactly in your computer anyway, so you would not get an exact cube root this way; e.g.: R> format((1234567891112^3)^(1/3),digits=16) [1] "1234567891112.001" (Probab

Re: [R] CPU Usage with R 2.1.0 in Windows

2005-07-20 Thread davidr
If you set the affinity of the R process to processor 0, you can run another (R or other) process with affinity set to processor 1 and get 100% usage. Most applications can't take advantage of hyperthreading (or multiprocessors), since they have to be specially written to do so. It seems that pa

Re: [R] creating a color display matrix

2006-07-26 Thread davidr
?image has worked for me. David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kartik Pappu Sent: Wednesday, July 26, 2006 3:30 PM To: r-help@stat.math.ethz.ch Subject: [R] creating a

Re: [R] listing of permutations

2006-08-02 Thread davidr
not very-well hidden: permutations in (e1071) permn in (combinat) David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erin Hodgess Sent: Wednesday, August 02, 2006 11:57 AM To: r-hel

Re: [R] Permutations with replacement

2006-08-18 Thread davidr
If you also want 1,1,1 and so on, the number of these is n^n, (n choices for each of n slots.) In that case, you could use hcube from combinat. David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of

[R] R at the Language Log

2007-03-23 Thread davidr
I was pleasantly surprised in my visit to the Language Log to see R used: "These days, the most straightforward way to answer a question like this is to do a Monte Carlo simulation. This is easy to do, e.g. in the (free software) statistics language R :" http://i

Re: [R] Deming regression

2007-04-05 Thread davidr
Looking in the archives for Deming regression brings up a previous reply of mine: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/57384.html , which may shed some light. David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED]

Re: [R] difference between 2 dates: IN MONTHS the way Mothers compute it

2006-03-10 Thread davidr
I just solved this for dealing with deliverables for the CBOT's treasury futures. length(seq(from=x, to=y, by="months"))-1 David L. Reiner > -Original Message- > From: [EMAIL PROTECTED] [mailto:r-help- > [EMAIL PROTECTED] On Behalf Of Smith, Phil > Sent: Friday, March 10, 2006 12:

Re: [R] addition using binary

2006-03-28 Thread davidr
Looks as if you are dealing with bond prices (or futures, which are quoted in 32nds), and someone has been creative with the way they store them. I would convert them all to doubles (represented exactly in the computer) and just add directly. x <- floor(p) + (p-floor(p))*100/32 . Finally, if you ne

Re: [R] Function for computing the difference between 2 dates inmonths

2006-04-19 Thread davidr
not without knowing what dados is. Remember that num.months works only on objects that can be converted to Date objects. Make sure that all of your date-like objects can be converted. (The error message seems to indicate that something you think should look like a date doesn't.) David L. Reiner

[R] dyn.load Excel add-in on Windows XP and XLCall32.dll

2005-01-10 Thread davidr
I am on Win XP SP2 using R 2.0.1 patched. I could not find anything apropos in the archives or with search engines. (But maybe I need to be taught how to search better.) I am trying to dyn.load some commercial DLLs (Excel add-ins), but I get a message box saying: "This application has failed to s

RE: [R] spreadsheet addiction

2005-01-14 Thread davidr
I get around the dependence on how things are displayed in Excel by using VBA to write my data files. Then you get full precision and you can use white space as a separator if you like. Sub WriteRangeToFile(rData as Excel.Range, fName as String) Application.ScreenUpdating = False Application

RE: [R] Straight-line fitting with errors in both coordinates

2005-01-21 Thread davidr
You want to look in the archives or elsewhere online for "errors in variables" or "total least squares". There are many resources. Note that the method in NR assumes both variables have equal-sized observational errors. If that is not the case for your data, then the method is inappropriate. HTH,

RE: [R] combinations without repetition

2005-02-14 Thread davidr
These would more properly be called permutations of a multiset. You can find code on the net by searching for "generate permutations multiset" (though not in R AFAICS.) David L. Reiner -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Sunday, February 13, 2005 8:

RE: [R] 'combinations' in gtools and stack overflow

2005-02-14 Thread davidr
combn in package combinat does not use recursion, and so may be simpler to use and may be able to do larger sets. David L. Reiner -Original Message- From: Warnes, Gregory R [mailto:[EMAIL PROTECTED] Sent: Monday, February 14, 2005 11:01 AM To: Ho-Joon Lee Cc: r-help@stat.math.ethz.ch Sub

RE: [R] scaling axes when plotting multiple data sets

2005-02-16 Thread davidr
min, max, and range (and many other functions) take the na.rm parameter to ignore NAs, but the Infs must be removed by hand as far as I know: dat <- c(data1,data2,data3,data4) dat <- dat[(dat!=Inf)&(dat!=(-Inf))] rng <- range(dat, na.rm=TRUE) then use xlim = rng -- David Reiner -Original Mes

RE: [R] Sorting a matrix on two columns

2005-02-22 Thread davidr
Perhaps I read more into the question than others, but I thought he was asking about a stable sort. If that is the case, ?order says that the sort is stable except for method = "quick". David L. Reiner -Original Message- From: Rau, Roland [mailto:[EMAIL PROTECTED] Sent: Monday, February

[R] Can I find the datetime an object was last assigned to/saved?

2004-09-13 Thread davidr
I'm using v 1.9.1 under Windoz XP. Can I do the equivalent of "ls -l" on my R objects? R's "ls()" lists only the names. Thanks! David L. Reiner Rho Trading 440 S. LaSalle St -- Suite 620 Chicago IL 60605 312-362-4963 (voice) 312-362-4941 (fax) [[alternative HTML v

[R] How to print landscape from script in Windows: dev.print(win.print, printer="local printer name", ...) does not accept horizontal=TRUE

2004-09-29 Thread davidr
This is a windows-specific question. After generating a plot, I can print from scripts or the command line with > dev.print(win.print,printer="local windows printer name") I would like to print in landscape mode. From the menus, I can accomplish this by changing the properties of the p

RE: [R] Can grid lines color in a plot be specified?

2004-10-01 Thread davidr
I usually use something like abline(h=seq(...),col="green") abline(v=seq(...),col="green") This allows you to have irregularly spaced grid lines if you want. (Say for futures expiration dates in my case.) Also, as Marc pointed out, you may want to draw the lines or points after the grid lines.

[R] can one evaluate an expression in a comment? (or insert results into history?)

2004-11-08 Thread davidr
I'd like to insert (for example) the current datetime into a comment so it goes into the history. I can of course cut and paste the results of date() into a comment line, but it would be easier and more powerful to be able to type something like > hstamp() and have it go into the history. Mor

RE: [R] can one evaluate an expression in a comment? (or insert resultsinto history?)

2004-11-08 Thread davidr
But that doesn't put the result into the history buffer, to be written to a file only later when I savehistory(filename). Bert Gunter also suggested ?capture.output and ?textConnection, but I cannot see how to get text into the history buffer as comments, but with evaluated expressions (values).

RE: Re: [R] 3d scatter plot with drop line

2004-11-18 Thread davidr
Very nice! I noticed that you wrote the function to drop points to any surface. Is it possible to add the surface to the plot as a translucent surface, so the points and drop lines still show? David L. Reiner -Original Message- From: Robin Hankin [mailto:[EMAIL PROTECTED] Sent: Thursday,

Re: [R] The Perils of PowerPoint

2005-09-02 Thread davidr
> -Original Message- > From: ... Robert Baer > Sent: Friday, September 02, 2005 11:30 AM > It is wrong to blame ANY tool for our own shortcomings! Surely a fortune! David L. Reiner __ R-help@stat.math.ethz.ch mailing list https://st

Re: [R] Bug report on get.hist.quote

2005-11-02 Thread davidr
Perhaps you forgot that currency pairs are named upsidedown; e.g., USD/JPY is yen per dollar? (This is sometimes written USD-JPY to try to avoid the confusion. It is read "dollar-yen".) David L. Reiner > -Original Message- > From: [EMAIL PROTECTED] [mailto:r-help- > [EMAIL PROTECTED] On

Re: [R] Element-by-element multiplication operator?

2005-11-09 Thread davidr
A*B David L. Reiner > -Original Message- > From: [EMAIL PROTECTED] [mailto:r-help- > [EMAIL PROTECTED] On Behalf Of Gates, Michael BGI SF > Sent: Wednesday, November 09, 2005 1:26 PM > To: r-help@stat.math.ethz.ch > Subject: [R] Element-by-element multiplication operator? > > Is there

[R] origin and "origin<-" functions on chron

2005-11-15 Thread davidr
I'm trying to use/modify some code I found (at Omegahat, but I've seem similar usage elsewhere.) It contains the lines: if(any(origin(chronDate)!=orig)) origin(chronDate) <- orig Let's say: > require("chron") [1] TRUE > chronDate <- chron("11/15/2005", format="m/d/y", origin.=c(12,31,189

[R] COM dates (was origin and "origin<-" in chron)

2005-11-16 Thread davidr
I was just looking for an easy way to convert between COM datetime and chron datetime (both ways.) I found examples on the list, but they involved origin. Does anyone have functions for converting COM datetime <-> chron datetimethat work "safely"? David L. Reiner > -Original Mes

Re: [R] Exponentially Weighted Moving Average

2007-07-03 Thread davidr
You could use rollFun from fMultivar package. You need to define your EWMA function separately. (Usually the EWMA moves along with a constant window size, though ) David L. Reiner Rho Trading Securities, LLC 550 W. Jackson Blvd #1000 Chicago, IL 60661-5704 312-244-4610 direct 312-244-4500 ma

Re: [R] EWMA in fMultivar

2007-07-03 Thread davidr
To calculate variance (assuming zero mean, as is usual), you would use returns^2. You will have to examine the code by typing EWMA to see what it's doing and how to change it. The code is clear enough that you could make your own version to achieve what you want. HTH, David L. Reiner Rho Trading

Re: [R] set up automatic running of R

2007-07-18 Thread davidr
Just create a batch file, say myproc.bat with the line C:/pathtoR/bin/R CMD BATCH myscript.R and use the Windows task scheduler to schedule your job. (Drag your batch file into C:/WINDOWS/Tasks, change its name if you like, and right click to Properties to schedule it and set other attributes.) H

Re: [R] [R-pkgs] New R package sqldf

2007-08-01 Thread davidr
It works after rm(list=ls()) I had a function called 'fn'; if I had paid close attention when I loaded gsubfn, I would have seen the warning. My fault. Thanks again for a most useful package! David L. Reiner Rho Trading Securities, LLC -Original Message- From: Gabor Grothendieck [mail

Re: [R] Need to fit a regression line using orthogonal residuals

2007-01-31 Thread davidr
This problem also comes up in financial hedging problems, but usually the 'errors' need not be of comparable size, so Errors in Variables or Total Least Squares might be used. David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTE

Re: [R] Fatigued R

2007-02-13 Thread davidr
I can't be sure what is happening to Shubhak, but I know that the Bloomberg server bbcomm.exe throws unhandled exceptions in a unreproducable and uncatchable way, somewhere in their tcp code. It is one of the big frustrations for me in my work. Shubhak, I think you will just have to look caref

[R] Standard Deviation Distribution

2006-06-15 Thread davidr
I'm having trouble with the standard deviation distribution as shown on http://mathworld.wolfram.com/StandardDeviationDistribution.html . (Eric Weisstein references Kenney and Keeping 1951, which I can't check.) I believe the graphs they show, but when I code the function in R, according to the l

Re: [R] help with table partition

2006-06-15 Thread davidr
apply(log(P), 2, diff) David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wong, Kim Sent: Thursday, June 15, 2006 11:30 AM To: Petr Pikal; Jacques VESLOT Cc: r-help@stat.math.ethz.ch

[R] Standard Deviation Distribution - solved

2006-06-15 Thread davidr
It turns out that I was confused by Weisstein's double use of the variable s. sigma^2 = N*(observed s)/(N-1), hence constant in the function. So > sddist <- function(s,s0,n) { sig2 <- n*s0*s0/(n-1) 2*(n/(2*sig2))^((n-1)/2) / gamma((n-1)/2) * exp(-n*s*s/(2*sig2)) * s^(n-2) } gives the plots on

Re: [R] Stirling numbers

2006-07-19 Thread davidr
Well, given Martin's 2nd kind function and the fact that the 1st and 2nd kind matrices are inverses, you can get at least some of what you want by: ... # fill a matrix S2 with second kind numbers and zeros > S2 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,]1000000 [2,]

[R] unique, but keep LAST occurence

2006-07-24 Thread davidr
?unique says Value: An object of the same type of 'x'. but if an element is equal to one with a smaller index, it is removed. However, I need to keep the one with the LARGEST index. Can someone please show me the light? I thought about reversing the row order twice, but I couldn't get

Re: [R] unique, but keep LAST occurence

2006-07-24 Thread davidr
Thank you, Bert and Mark. I believe Mark's solution works, but it was taking a very long time. Bert's is very fast. My day is saved! David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: Berton Gunter [mailto:[EMAIL PROTECTED] Sent: Monday,

Re: [R] read.fwf and header

2006-10-31 Thread davidr
"Archaic" it may be, but I still have to deal with fixed format data files on a daily basis. David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Maechler Sent: Tuesday, October

Re: [R] Fetching Intraday data from Bloomberg

2006-11-14 Thread davidr
na.action="bloomberg.handles" will leave out any bars with no data. I don't see a way to get just trading days but take fill action (prev or na) if there is no data for a bar on a trading day. This is the same in the API. The periodicity parameter doesn't make sense in this context. David L. Re

Re: [R]

2006-11-16 Thread davidr
I seem to get that error/warning "NA's introduced due to Coercion" when I ask for too much intraday data at once. There are limits to what can come back in one call, and probably the error checking/correcting needs help. Why not take a look at the R code and see if you have any ideas. It might be a

Re: [R] RBloomberg Multi-ticker problem

2006-11-22 Thread davidr
Bloomberg recommends getting only one ticker at a time for intraday data. David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Wednesday, November 22, 2

RE: [R] Bloomberg data import

2005-03-28 Thread davidr
Pasad, I think GetHistoricalData might work for tick data. (At least it does from VB and VBA.) HTH, David L. Reiner p.s. Static data was mentioned, and that you get with Subscribe. -Original Message- From: Chalasani, Prasad [mailto:[EMAIL PROTECTED] Sent: Thursday, March 24, 2005 3:10 PM

RE: [R] Bloomberg data import SOLVED

2005-03-31 Thread davidr
Together with Enrique's running start and Prasad's work, we figured out how to get tick data and bulk data from Bloomberg into R. Here is a code snippet which builds on Enrique's. require("RDCOMClient") blCon <<- try(blCon <- COMCreate("Bloomberg.Data.1"), silent=TRUE

RE: [R] A question about function behavior

2005-04-20 Thread davidr
?pmax David L. Reiner -Original Message- From: Jorge Ahumada [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 20, 2005 12:03 PM To: r-help@stat.math.ethz.ch Subject: [R] A question about function behavior Hello, I have been trying to figure this one out, but don't seem to go anywhere.

[R] R 2.1.0 for Windows installation error? atanh not in R.dll?

2005-04-21 Thread davidr
ckages") was not found I also tried 2.1.0 patched and got the same results. Of course, I cannot do much without the stats package. stats.dll does exist in that location: [EMAIL PROTECTED] /cygdrive/c/R/rw2010/library/stats/libs $ ls -lA total 207 -rwx--+ 1 davidr 211456 Apr 18

[R] DOH! RE: R 2.1.0 for Windows installation error? atanh not in R.dll?

2005-04-21 Thread davidr
ssage: package stats in options("defaultPackages") was not found I also tried 2.1.0 patched and got the same results. Of course, I cannot do much without the stats package. stats.dll does exist in that location: [EMAIL PROTECTED] /cygdrive/c/R/rw2010/library/stats/libs $ ls -lA total 207 -rwx--+

[R] standard errors for orthogonal linear regression

2005-04-28 Thread davidr
Could someone please help me by giving me a reference to how one computes standard errors for the coefficients in an orthogonal linear regression, or perhaps someone has some R code? (I would accept a derivation or formula, but as a former teacher, I know how that can rankle.) I tried to imitate

[R] Choices from a matrix

2005-05-06 Thread davidr
Could someone please suggest a more clever solution to the following problem than my loop below? Given X a 2xN matrix X, and I a k-subset of N, Generate the (2^k)xN matrix Y with columns not in I all zero and the other columns with all choices of an entry from the first or second row of X. For

RE: [R] Choices from a matrix

2005-05-06 Thread davidr
Thanks, Bert, but when I tried that, I didn't get a matrix: > newX [[1]] [1] 1 2 1 2 [[2]] [1] 5 5 6 6 [[3]] [1] 1 2 1 2 [[4]] [1] 5 5 6 6 [[5]] [1] 0 [[6]] [1] 0 [[7]] [1] 0 [[8]] [1] 0 [[9]] [1] 1 2 1 2 [[10]] [1] 5 5 6 6 [[11]] [1] 1 2 1 2 [[12]] [1] 5 5 6 6 [[13]] [1] 0 [[14]] [1]

RE: [R] Choices from a matrix

2005-05-06 Thread davidr
Bert, that was almost it, we just need one more as.matrix: newX[,I]<-as.matrix(expand.grid(as.list(as.data.frame(X[,I] This works as advertised. Best regards, David p.s. I agree that the extra as.list is counterintuitive. It might be nice if there were a matrix form of expand.grid. -Or