[R-SIG-Finance] [R-sig-finance] Downloading data from specific website
ggrothendieck at gmail.com
Thu Jun 18 22:48:23 CEST 2009
Try this. First we read in the entire page line by line into Lines
and find the index, ix, of the line starting with <. st is its
value as a character string after stripping off junk. Then we
re-read the page from the text we already downloaded but this
time as a table skipping the first ix lines and finally we
convert it to zoo using as.yearqtr(st) as the start quarter.
> URL <- "http://www.jmulti.de//download/datasets/e6.dat"
> Lines <- readLines(URL)
> ix <- grep("^<", Lines)
> st <- sub("[<> ]", "", Lines[ix])
> DF <- read.table(textConnection(Lines), skip = ix, header = TRUE)
> z <- zooreg(as.matrix(DF), start = as.yearqtr(st), freq = 4)
1972 Q2 -0.003132580 0.083
1972 Q3 0.018871300 0.083
1972 Q4 0.024803600 0.087
1973 Q1 0.016277600 0.087
1973 Q2 0.000289679 0.102
1973 Q3 0.016829000 0.098
On Thu, Jun 18, 2009 at 3:58 PM, Bogaso<bogaso.christofer at gmail.com> wrote:
> I need to download some econometric data from http://www.jmulti.de/
> The path is :
> Datasets -> Download data (2nd link) -> e6.dat
> I prefer the downloaded data as a zoo object. How can I develop some R
> function to do that? Your help will be highly appreciated.
> View this message in context: http://www.nabble.com/Downloading-data-from-specific-website-tp24099586p24099586.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
> R-SIG-Finance at stat.math.ethz.ch mailing list
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
More information about the R-SIG-Finance