[R] Downloading data from from internet
Gabor Grothendieck
ggrothendieck at gmail.com
Sat Sep 26 12:17:48 CEST 2009
Here are three different approaches:
1. Using the first link as an example, on Windows you can copy the
data and headers from IE (won't work in Firefox) to Excel and from
there to clipboard again and then in R:
library(zoo)
DF <- read.delim("clipboard")
z <- zooreg(c(t(DF[5:1, 2:13])), start = as.yearmon("2005-01"), freq = 12)
2. on any platform you can read it straight into R:
L <- readLines("http://www.rateinflation.com/consumer-price-index/usa-cpi.php")
and then use the character manipulation functions (grep, sub, gsub,
substr) and as.numeric to parse out the data or
3. on any platform, use the XML package adapting the code in this post:
https://stat.ethz.ch/pipermail/r-help/2009-July/203063.html
On Thu, Sep 24, 2009 at 9:34 AM, Bogaso <bogaso.christofer at gmail.com> wrote:
>
> Hi all,
>
> I want to download data from those two different sources, directly into R :
>
> http://www.rateinflation.com/consumer-price-index/usa-cpi.php
> http://eaindustry.nic.in/asp2/list_d.asp
>
> First one is CPI of US and 2nd one is WPI of India. Can anyone please give
> any clue how to download them directly into R. I want to make them zoo
> object for further analysis.
>
> Thanks,
> --
> View this message in context: http://www.nabble.com/Downloading-data-from-from-internet-tp25568930p25568930.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list