[R-SIG-Finance] [R-sig-finance] Downloading data from specific website
Bogaso
bogaso.christofer at gmail.com
Sun Jun 21 10:05:20 CEST 2009
Thanks everyone it is working. However interested to know, how you define the
URL i.e. "http://www.jmulti.de//download/datasets/e6.dat"?
If I go 1st "http://www.jmulti.de" and then click on "Datasets" and then
"Download data, 2nd link", I see no change in the address bar. What is the
magic here? Can you please clarify me? If I choose to go with "Download
data, 1st link" then what would be the strategy?
Thanks and regards,
Gabor Grothendieck wrote:
>
> 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.
>
>> library(zoo)
>> 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)
>> head(z)
> Dp R
> 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:
>>
>> Hi,
>>
>> 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.
>>
>> Regards,
>> --
>> 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
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only.
>> -- If you want to post, subscribe first.
>>
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
>
--
View this message in context: http://www.nabble.com/Downloading-data-from-specific-website-tp24099586p24132322.html
Sent from the Rmetrics mailing list archive at Nabble.com.
More information about the R-SIG-Finance
mailing list