[R-SIG-Finance] Delete bad dividend row

Frank frankm60606 at gmail.com
Mon Jul 1 01:29:59 CEST 2013


Hi Garret,

That did help. I've been analyzing dividend yields and the quantmod
getDividends and getSymbols work flawlessly. But then the dividends change
frequency over time, special dividends creep in and now a spurious data
point for PM. So far I've dealt with these with your help and others. 

Best,

Frank

-----Original Message-----
From: G See [mailto:gsee000 at gmail.com] 
Sent: Sunday, June 30, 2013 5:15 PM
To: Frank
Cc: r-sig-finance
Subject: Re: [R-SIG-Finance] Delete bad dividend row

Hi Frank,

There are a few ways to do it.

library(quantmod)
div <- getDividends("PM", from="2010-01-01")

# find the row(s) you want to remove and use negative indexing
div[-12]
div[-which(div == 0.039)]
div[-div["2012-12-20", which.i=TRUE]]

# exclude specific date by passing logical vector to [.xts
div[!index(div) %in% as.Date("2012-12-20")]

# exclude specific weekdays
div[weekdays(index(div)) != "Thursday"]
div[as.POSIXlt(index(div))$wday != 4]

# exclude amounts smaller than some arbitrary number
div[div > 0.1]
# exclude specific amount
div[div != 0.039]

HTH,
Garrett



More information about the R-SIG-Finance mailing list