Posted By


crock1255 on 05/27/11

Tagged


Statistics


Viewed 99 times
Favorited by 0 user(s)

Raleigh Climate


/ Published in: R
Save to your folder(s)



Copy this code and paste it in your HTML
  1. rm(list=ls())
  2. setwd(/Users/jonathancoleman/Dropbox/R)
  3. library(XML)
  4. climate_url <- "http://www.climate-zone.com/climate/united-states/north-carolina/raleigh/" # assign URL
  5. climate_tables <- readHTMLTable(climate_url) #Read HTML in URL
  6. climate_tables <- climate_tables[[13]] #Extract table 13 from URL
  7. climate_tables <- climate_tables[-1,] #Delete Row 1
  8. names(climate_tables) <- c("Raleigh Temperature", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Annual") #Rename headers
  9. climate_tables <- climate_tables[-15,] #remove row 15
  10. climate_tables <- climate_tables[-10,] #remove row 10
  11. climate_tables <- climate_tables[-6,] #remove row 6
  12. row.names(climate_tables) <- c("Avg. Temp", "Avg. Max Temp.", "Avg. Min Temp.", "Days with Max Temp >= 90 F", "days with Min Temp Below Freezing", "Raleigh Heating and Cooling", "Heating Degree Days", "Cooling Degree Days", "Raleigh Precipitation (inches)", "Precipitation (inches)", "Days with Precipitation >= 0.01 inches", "Monthly Snowfall (inches)", "Other Raleigh Weather Indicators", "Avg Wind Speed", "Clear Days", "Partly Cloudy Days", "Cloudy Days", "Percent of Possible Sunshine", "Avg. Relative Humidity") #rename rows
  13. climate_tables <- climate_tables[,-1] #remove column 1
  14. as.data.frame(climate_tables) #set as data.frame
  15. climate_tables <- rnorm(climate_tables, mean = 0) #set means equal to zero

URL: Raleigh_Climate

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.