[R-SIG-Finance] List index constituents of an index in R? quantmod?

Vincent Zoonekynd zoonek at gmail.com
Wed Jan 4 13:47:31 CET 2012


You can use the XML package to parse the page and extract the contents
of the table:
  library(XML)
  index <- "^DJI"
  url <- paste("http://uk.finance.yahoo.com/q/cp?s=", index, sep="")
  symbols <- readHTMLTable(url, as.data.frame=FALSE)[[10]]$Symbol

You should check the size of the result: large indices may be split
across several pages, and the layout of the page may change.

-- Vincent

On 4 January 2012 21:24, julien cuisinier <j_cuisinier at hotmail.com> wrote:
> Is anyone aware of an existing function to download from yahoo finance
> the list of an index constituents?



More information about the R-SIG-Finance mailing list