Re: [R] Exporting animation of a series of plots

2010-03-12 Thread davidr
I think you can use package animation. See http://animation.yihui.name/ . HTH, David L. Reiner -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Flana Sent: Friday, March 12, 2010 12:14 PM To: r-help@r-project.org Subject: [R] Exportin

Re: [R] plotting a subset of a time series

2010-03-02 Thread davidr
The indexing in xts is very nice; it may do what you want. library(xts) x.xts <- as.xts(x) plot(x.xts) plot(x.xts['2005::2006-10']) HTH, David Reiner -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erin Hodgess Sent: Tuesday, March

Re: [R] Integral of function of dnorm

2010-02-11 Thread davidr
and it can be done analytically: = -(1 + log(2 pi)) / 2 -- David L. Reiner -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Greg Snow Sent: Thursday, February 11, 2010 11:58 AM To: Trafim Vanishek; Peter Dalgaard Cc: r-help@r-project

Re: [R] [SPAM] - help with regular expressions in R - Bayesian Filter detected spam

2009-08-20 Thread davidr
Possibly just a typo: > gsub('\\[.*\\]', '', myCharVec) ^^ [1] """(the rain in spain)" HTH, -- David -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mark Kimpel Sent: Thursday, August 20, 2009 10:31 A

Re: [R] Help with reshaping data.frame

2009-08-04 Thread davidr
Thanks to Hadley (shortest and sweetest), Eric and Gabor. I was _so_ close. Now I think I've learned some things about the reshape function and package! (Also transform and interaction.) Thanks to you all, -- David -Original Message- From: hadley wickham [mailto:h.wick...@gmail.com] Sent

[R] Help with reshaping data.frame

2009-08-03 Thread davidr
I'm having trouble reshaping a data.frame from long to wide. (I think that's the right terminology; feel free to educate me.) I've looked at the reshape function and package and plyr package, but I can't quite figure out how to do this after a dozen variations. I have a data.frame with more level

Re: [R] Elementary Symmetric Polynomials

2009-07-23 Thread davidr
How's this? f2 <- function(v) { n <- length(v) s <- matrix(0,n,n) for(i in 1:n) for(j in 1:i) s[j,i] <- ifelse(i>1, s[j,i-1]+v[i]*ifelse(j>1, s[j-1,i-1], 1), v[i]) c(1,s[,n]) } > system.time(f2.result <- f2(1:20)) user system elapsed 0 0 0 > system.time(f

Re: [R] how to undo automatic loading of packages?

2009-06-24 Thread davidr
I removed all of the objects that were from the examples I tried, saved, and quit. R starts up cleanly now. Yeah! That was annoying behavior, and I would recommend that the authors change it, please. Thank you for your to-the-point advice, Professor Ripley! -- David ps - Sorry for the lengthy dis

[R] how to undo automatic loading of packages?

2009-06-24 Thread davidr
I wanted to try out package distrMod, so I did > install.packages('distrMod') > library(distrMod) and played around, saved and quit. Now whenever I start up in this directory, I get distr and lots of other stuff loaded and lots of messages. How do I keep it from automatically loading, other tha

Re: [R] Website, book, paper, etc. that shows example plots of distributions?

2009-02-13 Thread davidr
Jason, Just to answer your direct question, there is Mathowrld.wolfram.com, where there are 87 continuous distributions listed. I have also used the book Statistical Distributions, 2nd ed, Merran Evans, et al. which has most of the usual distributions with pictures and relationships. Of course al

Re: [R] list.files changed in 2.7.0

2009-02-04 Thread davidr
My original message referred to the double slash and using grep. The particular behavior on C: wasn't the issue. For example, > list.files("C:/test1", full.names=TRUE) [1] "C:/test1/file1" "C:/test1/file2" > list.files("C:/test1/", full.names=TRUE) [1] "C:/test1//file1" "C:/test1//file2" > # Note

Re: [R] scoping rules for 'for' [was - Re: for/if loop ]

2009-01-29 Thread davidr
The lines below made me understand clearly. Maybe they are already in some documentation, but if not, it might help others to avoid my misunderstanding. Thanks to all for the clarifications. -- David -Original Message- From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] Sent: Thursday, Ja

Re: [R] scoping rules for 'for' [was - Re: for/if loop ]

2009-01-29 Thread davidr
I apologize for posting a wrong opinion; I should of course have checked before posting. Henrik's examples illustrate something I had never realized before, and it really surprised me! Where can I read the technical details of this scoping aspect of 'for' as it still presents some subtle puzzles f

Re: [R] [SPAM] - Re: for/if loop - Bayesian Filter detected spam

2009-01-28 Thread davidr
Well, maybe you are just bad at typing then ;-) The lines rr==ii, pp==pp+1, etc. are not setting rr and pp but comparing them. Probably you want rr <- ii and pp <- pp+1, etc. And the last line of your loop 'ii=ii+1' means that, since the for statement is already incrementing ii, you are incrementi

Re: [R] list.files changed in 2.7.0

2009-01-26 Thread davidr
Hmm. I get exactly the same files and directories with "C:" and "C:/", except for the double slashes now. Previously the two calls to list.files gave exactly the same results. My current directory (getwd()) is not C:. I'm puzzled by your output. -- David -Original Message- From: henrik.be

[R] list.files changed in 2.7.0

2009-01-23 Thread davidr
I just noticed a change in the behavior of list.files from 2.6.1pat to 2.7.0 (I noticed it in 2.8.1 and traced back.) Previously, if the directory ended with a slash, and full.names=TRUE, the names returned had a single slash at the end of the directory, but now there are two. I noticed since I

Re: [R] meaning of asymmetric on help page for intersect

2009-01-13 Thread davidr
There is also a symmetric set difference = union(setdiff(x, y), setdiff(y, x)) denoted x \Delta y -- David -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Juliet Hannah Sent: Tuesday, January 13, 2009 9:41 AM To: r-help@r-project.o

Re: [R] [SPAM] - How can I generate a random order? - Found word(s) remove list in the Text body

2008-11-12 Thread davidr
sample(1:100) -- David -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stuart Leask Sent: Wednesday, November 12, 2008 2:24 PM To: [EMAIL PROTECTED] Subject: [SPAM] - [R] How can I generate a random order? - Found word(s) remove list in the Text body F

Re: [R] substring/strsplit question

2008-10-29 Thread davidr
How about > x <- c("2E","5W","12H") > substr(x, nchar(x), nchar(x)) [1] "E" "W" "H" > > substr(x, 1, nchar(x)-1) [1] "2" "5" "12" -- David -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erin Hodgess Sent: Wednesday, October 29, 2008 3:58 PM To: [EMA

Re: [R] RBloomberg to get dividend

2008-10-03 Thread davidr
Try adding ret="raw" and leaving off start= since that is not supported for data set requests. You'll just have to format the returned nested lists yourself. Looking at the RBloomberg code should give you hints. (Also I think that field is deprecated - at least I can't find it in my version, but it

Re: [R] Generating a valid covariance matrix

2008-09-26 Thread davidr
Depending on what you want your covariance matrices to be like, you could form random symmetric matrices with positive diagonals and then use nearPD {Matrix} to make them positive definite, but the resulting distribution of covariance matrices would be hard to guess. And giving a diagonal matrix

Re: [R] [SPAM] - Re: Bug in "is" ? - Found word(s) list error in the Text body

2008-09-26 Thread davidr
If one looks at the other is.* functions or ?mode, one will quickly see that each is.* function does something specific and not 'what one would expect'. For example, is.real and is.complex do not tell you whether the argument has a zero complex part or not. Another example is all.equal. If one

Re: [R] yahoo finance into R

2008-09-10 Thread davidr
Yahoo and OandA provide only daily data, but the history goes back quite a ways: > msft <- get.hist.quote(instrument="MSFT", start="1986-03-31", > end="2008-09-10", quote=c("O","H","L","C","A","V"), provider="yahoo", > retclass="zoo") > NROW(msft) [1] 5663 That's 22 years of data. Not sure what y

Re: [R] casting help please

2008-09-05 Thread davidr
I think I just remembered that in a melted data.frame the values have to be called 'value' and tried renaming my third column so. Now it works (without add.missing). Thanks for this powerful piece of software! -- David (I was trying to convert a set of data in 'long' format to 'wide' format. Basic

[R] casting help please

2008-09-05 Thread davidr
I have a data.frame which I believe is melted already and am having trouble casting it to 'wide' format. It looks something like > (x <- data.frame(ticker=c(rep("A",5),rep("B",6)), date=c(1:5, 1:6), value=c(NA,100*exp(rnorm(10,0,.1) > cast(x, date ~ ticker) # this does what I want with to

Re: [R] Two envelopes problem

2008-08-25 Thread davidr
There's a pretty thorough discussion on Wikipedia http://en.wikipedia.org/wiki/Two_envelopes_problem Suffice it to say that not everyone agrees. -- David -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Deepayan Sarkar Sent: Monday, August 25, 2008 4:35 PM

Re: [R] Simple estimate of a probability by simulation

2008-08-20 Thread davidr
I get 5/36 + log(2)/6, not 1/9. David L. Reiner, PhD Head Quant Rho Trading Securities, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Monteiro Sent: Wednesday, August 20, 2008 7:56 AM To: Van Wyk, Jaap; r-help@r-project.org Subject: Re: [R]

Re: [R] [SPAM] - constructing arbitrary (positive definite) covariance matrix - Found word(s) list error in the Text body

2008-06-26 Thread davidr
Well, if you think about the geometry, all correlations equal usually won't work. Think of the SDs as the sides of a simplex and the correlations as the cosines of the angles between the sides (pick one variable as the 'origin'.) Only certain values will give a valid covariance or correlation matri

Re: [R] automation of R? running an R script at a certain time eachnight?

2008-05-22 Thread davidr
I do this all the time. See http://finzi.psych.upenn.edu/R/Rhelp02a/archive/105099.html (Vista is a bit harder than XP, but similar.) As far as determining when to proceed with the script, you could have your db updater create a semaphore file your batch or R script could wait for. HTH, David L.

Re: [R] How to remove double loop?

2008-03-19 Thread davidr
Jonas, Take a look at CRRBinomialTreeOption{fOptions} in which Diethelm Wuertz uses a double loop, but of course, he's optimized it to use only a vector instead of a matrix! David L. Reiner, PhD Head Quant Rho Trading Securities, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:[EM

Re: [R] R Finance

2008-03-13 Thread davidr
I guess I would create a mapping table to convert between the symbols from Bloomberg and from Yahoo. You should be able to just create it once and add to it as new symbols appear on your screens. Most of the symbols should be the same so you could omit those. If it all has to be automated, you coul

Re: [R] plot.zoo warnings - ignore or look for problem?

2008-03-11 Thread davidr
That did it, Gabor. Thanks! I didn't think chron would be involved. -- David -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2008 11:39 AM To: David Reiner <[EMAIL PROTECTED]> Cc: r-help@r-project.org Subject: Re: [R] plot.zoo warnings - ig

[R] plot.zoo warnings - ignore or look for problem?

2008-03-11 Thread davidr
I'm getting warnings when I plot a zoo object: > dts <- chron(rep("2007-09-10", 5), paste("00:0", 0:4, ":00", sep=""), c("y-m-d", "h:m:s")) > dat.zoo <- zoo(1:5, dts) > plot(dat.zoo) Warning messages: 1: In v[[perm[1]]] : partial match of 'm' to 'month' 2: In v[[perm[2]]] : partial match of 'd' to

Re: [R] recursive function help SOLVED (sort of)

2008-02-20 Thread davidr
Well, it turns out to be very simple - just insert a Vectorize between integrate and function(x). However, the special cases where C[i,j]==1 make the actual code quite messy. It matches pmvnorm {mvtnorm} and pmnorm {mnormt} quite well. And the recursive method is incredibly slow for higher dimensio

[R] recursive function help

2008-02-19 Thread davidr
I'm trying to implement a recursive function using integrate, and I suspect I need a Vectorize somewhere, but I can't suss it out. Any help would be appreciated. I've tried traceback() and various debugging ideas to no avail (most likely due to my inexperience with these tools.) Here's what I have

Re: [R] book on regular expressions

2007-12-11 Thread davidr
I've found the O'Reilly pocket reference "Regular Expression" (about USD 10.00) quite handy. It covers Perl, C, PHP, Python, Java, and .Net. David L. Reiner Rho Trading Securities, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christos Hatzis Sent:

Re: [R] Problem in extracting EQY_DVD_HIST from Bloomberg

2007-09-18 Thread davidr
I'd guess start and end are confusing the bulk data call (it doesn't take those params). This works for me: div <- blpGetData(con, "IBM Equity", "EQY_DVD_HIST", retval="raw") You need the "raw" retval when anything is not numeric; then you need to extract the bits you want from the nested list re

Re: [R] ISIN numbers into Bloomberg tickers

2007-09-14 Thread davidr
You can try > blpGetData(conn, "US912828HA15 Govt", c("ticker", "cpn", "maturity", "market_sector_des"), retval="raw") and paste together the parts. HTH, David L. Reiner Rho Trading Securities, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of

Re: [R] Yahoo data feed in R / Corporate Actions

2007-09-14 Thread davidr
This came up last week on r-sig-finance: https://stat.ethz.ch/pipermail/r-sig-finance/2007q3/001686.html David L. Reiner Rho Trading Securities, LLC 550 W. Jackson Blvd #1000 Chicago, IL 60661-5704 312-244-4610 direct 312-244-4500 main 312-244-4501 fax -Original Message- From: [EMAIL