regex - Weather data scraping and extraction in R -


i'm working on research project , assigned bit of data scraping , writing code in r can extract current temperature particular zip code site such wunderground.com. may bit of abstract question know how following: can extract current temperature of particular zip code doing this:

    temps <- readlines("http://www.wunderground.com/q/zmw:20904.1.99999")     edit(temps)     temps //gives me source code website can @ line contains temperature     ldata <- temps[lnumber]     ldata     #  have few gsub functions extracts      # numerical data (57.8 example) line of code 

i have cvs file contains zip code of every city in country , have imported in r. arranged in table according zip, city , state. challenge write method (using java analogy here because i'm new r) extracts 6-7 consecutive zip codes (after particular 1 specified) , runs above code modifying link within readlines function , putting in respective zip code after link segment zmw:xxxxx , running after based on link. don't quite know how extract data table. maybe for-loop function? don't know how use modify link. think that's i'm getting stuck on. have bit of java background understand how approach problem, not knowledge of syntax. understand quite abstract question didn't provide lot of code want know functions/syntax me extract data table , somehow use modify link through function rather manually doing it.

so weather underground data.

you can download csv files individual weather stations in wunderground, need know weather station identifier. here example url weather station in kirkland, wa (kwakirkl8):

http://www.wunderground.com/weatherstation/wxdailyhistory.asp?id=kwakirkl8&day=31&month=1&year=2014&graphspan=day&format=1

here r code:

  url <- 'http://www.wunderground.com/weatherstation/wxdailyhistory.asp?id=kwakirkl8&day=31&month=1&year=2014&graphspan=day&format=1'   s <- geturl(url)   s <- gsub("<br>\n","",s)     wdf <- read.csv(con<-textconnection(s)) 

and here page can manually find stations , codes.

http://www.wunderground.com/wundermap/

since need few can pick them out manually.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -