[prev in list] [next in list] [prev in thread] [next in thread]
List: r-sig-finance
Subject: Re: [R-SIG-Finance] Delete bad dividend row
From: "Frank" <frankm60606 () gmail ! com>
Date: 2013-06-30 23:29:59
Message-ID: FB0EC0E80D0F4938B13B0DF4E2D82405 () Franki7PC
[Download RAW message or body]
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@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
_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic