Introduction

To understand the weather for SG over past years or months using library package - weatherData. Please read the pdf in the url below. It gives many comprehensive examples.

https://cran.r-project.org/web/packages/weatherData/index.html

suppressWarnings(suppressMessages(library(weatherData)))

station_id <- "SIN"

getCurrentTemperature(station_id) # check current temperature
##                   Time TemperatureC
## 23 2016-09-04 09:30:00           30
getDetailedWeather(station_id  , Sys.Date()) #just the Temperature Columns
##                   Time TemperatureC
## 1  2016-09-04 00:00:00           29
## 2  2016-09-04 00:30:00           29
## 3  2016-09-04 01:00:00           29
## 4  2016-09-04 01:30:00           29
## 5  2016-09-04 02:00:00           28
## 6  2016-09-04 02:00:00           28
## 7  2016-09-04 02:30:00           28
## 8  2016-09-04 03:00:00           28
## 9  2016-09-04 03:30:00           28
## 10 2016-09-04 04:00:00           28
## 11 2016-09-04 04:30:00           28
## 12 2016-09-04 05:00:00           27
## 13 2016-09-04 05:00:00           27
## 14 2016-09-04 05:30:00           27
## 15 2016-09-04 06:00:00           27
## 16 2016-09-04 06:30:00           27
## 17 2016-09-04 07:00:00           27
## 18 2016-09-04 07:30:00           27
## 19 2016-09-04 08:00:00           28
## 20 2016-09-04 08:00:00           29
## 21 2016-09-04 08:30:00           29
## 22 2016-09-04 09:00:00           30
## 23 2016-09-04 09:30:00           30
#what columns are available ?
showAvailableColumns(station_id, Sys.Date(), opt_detailed=T)
##    columnNumber            columnName
## 1             1               TimeSGT
## 2             2          TemperatureC
## 3             3            Dew_PointC
## 4             4              Humidity
## 5             5 Sea_Level_PressurehPa
## 6             6          VisibilityKm
## 7             7        Wind_Direction
## 8             8        Wind_SpeedKm_h
## 9             9        Gust_SpeedKm_h
## 10           10       Precipitationmm
## 11           11                Events
## 12           12            Conditions
## 13           13        WindDirDegrees
## 14           14               DateUTC
# interested in columns 12 - Conditions
df <- getDetailedWeather(station_id, Sys.Date(),opt_custom_columns=T, custom_columns=12)

head(df,10)
##                   Time    Conditions
## 1  2016-09-04 00:00:00 Mostly Cloudy
## 2  2016-09-04 00:30:00 Mostly Cloudy
## 3  2016-09-04 01:00:00 Mostly Cloudy
## 4  2016-09-04 01:30:00 Mostly Cloudy
## 5  2016-09-04 02:00:00          Haze
## 6  2016-09-04 02:00:00 Mostly Cloudy
## 7  2016-09-04 02:30:00 Mostly Cloudy
## 8  2016-09-04 03:00:00 Mostly Cloudy
## 9  2016-09-04 03:30:00 Mostly Cloudy
## 10 2016-09-04 04:00:00 Mostly Cloudy
#get 3 days temperature
d3 <- getWeatherForDate(station_id, start_date="2016-08-01", end_date = "2016-08-03", opt_detailed = TRUE, opt_all_columns = TRUE, opt_custom_columns=T, custom_columns = c(2,4,12))
## Getting data from:
##  http://www.wunderground.com/history/airport/SIN/2016/8/1/DailyHistory.html?format=1
## The following columns are available for:2016-08-01
##  [1] "TimeSGT"               "TemperatureC"         
##  [3] "Dew_PointC"            "Humidity"             
##  [5] "Sea_Level_PressurehPa" "VisibilityKm"         
##  [7] "Wind_Direction"        "Wind_SpeedKm_h"       
##  [9] "Gust_SpeedKm_h"        "Precipitationmm"      
## [11] "Events"                "Conditions"           
## [13] "WindDirDegrees"        "DateUTC"
## Getting data from:
##  http://www.wunderground.com/history/airport/SIN/2016/8/3/DailyHistory.html?format=1
## The following columns are available for:2016-08-03
##  [1] "TimeSGT"               "TemperatureC"         
##  [3] "Dew_PointC"            "Humidity"             
##  [5] "Sea_Level_PressurehPa" "VisibilityKm"         
##  [7] "Wind_Direction"        "Wind_SpeedKm_h"       
##  [9] "Gust_SpeedKm_h"        "Precipitationmm"      
## [11] "Events"                "Conditions"           
## [13] "WindDirDegrees"        "DateUTC"
## Checking Data Availability For SIN
## Found 28 records for 2016-08-01
## Found 28 records for 2016-08-03
## Data is Available for the interval.
## Will be fetching these Columns:
## 
##  Please note: Custom columns and opt_all_columns are both selected. 
##  Only custom columns will be returned.
## [1] "Time"         "TemperatureC" "Humidity"     "Conditions"
## Begin getting Daily Data for SIN
## 
##  Please note: Custom columns and opt_all_columns are both selected. 
##  Only custom columns will be returned.
## SIN 1 2016-08-01 : Fetching 56 Rows with 4 Column(s)
## 
##  Please note: Custom columns and opt_all_columns are both selected. 
##  Only custom columns will be returned.
## SIN 2 2016-08-02 : Fetching 56 Rows with 4 Column(s)
## 
##  Please note: Custom columns and opt_all_columns are both selected. 
##  Only custom columns will be returned.
## SIN 3 2016-08-03 : Fetching 56 Rows with 4 Column(s)
#display column 2, 4 and 12 as stated above
head(d3,20)
##                   Time TemperatureC Humidity    Conditions
## 1  2016-08-01 00:00:00           26       89 Mostly Cloudy
## 2  2016-08-01 00:30:00           26       89 Mostly Cloudy
## 3  2016-08-01 01:00:00           26       89 Mostly Cloudy
## 4  2016-08-01 01:30:00           26       94 Mostly Cloudy
## 5  2016-08-01 02:00:00           26       86          Haze
## 6  2016-08-01 02:00:00           26       94 Mostly Cloudy
## 7  2016-08-01 02:30:00           26       94 Mostly Cloudy
## 8  2016-08-01 03:00:00           26       94 Mostly Cloudy
## 9  2016-08-01 03:30:00           26       94 Mostly Cloudy
## 10 2016-08-01 04:00:00           26       94         Clear
## 11 2016-08-01 04:30:00           26       94         Clear
## 12 2016-08-01 05:00:00           26       92          Haze
## 13 2016-08-01 05:00:00           26       94 Mostly Cloudy
## 14 2016-08-01 05:30:00           26       94 Mostly Cloudy
## 15 2016-08-01 06:00:00           26       94 Mostly Cloudy
## 16 2016-08-01 06:30:00           25      100 Mostly Cloudy
## 17 2016-08-01 07:00:00           27       84 Mostly Cloudy
## 18 2016-08-01 07:30:00           27       79 Mostly Cloudy
## 19 2016-08-01 08:00:00           28       70          Haze
## 20 2016-08-01 08:00:00           28       74 Mostly Cloudy
# shows temperature for year 2016 (min, max and mean temperature)
year_temperature <- getWeatherForYear(station_id, 2016)
## Retrieving from: http://www.wunderground.com/history/airport/SIN/2016/1/1/CustomHistory.html?dayend=4&monthend=9&yearend=2016&req_city=NA&req_state=NA&req_statename=NA&format=1
## The following columns are available:
##  [1] "SGT"                        "Max_TemperatureC"          
##  [3] "Mean_TemperatureC"          "Min_TemperatureC"          
##  [5] "Dew_PointC"                 "MeanDew_PointC"            
##  [7] "Min_DewpointC"              "Max_Humidity"              
##  [9] "Mean_Humidity"              "Min_Humidity"              
## [11] "Max_Sea_Level_PressurehPa"  "Mean_Sea_Level_PressurehPa"
## [13] "Min_Sea_Level_PressurehPa"  "Max_VisibilityKm"          
## [15] "Mean_VisibilityKm"          "Min_VisibilitykM"          
## [17] "Max_Wind_SpeedKm_h"         "Mean_Wind_SpeedKm_h"       
## [19] "Max_Gust_SpeedKm_h"         "Precipitationmm"           
## [21] "CloudCover"                 "Events"                    
## [23] "WindDirDegrees"
## Checking Summarized Data Availability For SIN
## Found 248 records for 2016-01-01 to 2016-09-04
## Data is Available for the interval.
## Will be fetching these Columns:
## [1] "Date"              "Max_TemperatureC"  "Mean_TemperatureC"
## [4] "Min_TemperatureC"
# display first 5 rows and last 5 rows
head(year_temperature,5); tail(year_temperature,5)
##         Date Max_TemperatureC Mean_TemperatureC Min_TemperatureC
## 1 2016-01-01               29                27               24
## 2 2016-01-02               28                26               23
## 3 2016-01-03               27                24               23
## 4 2016-01-04               32                28               24
## 5 2016-01-05               32                29               26
##           Date Max_TemperatureC Mean_TemperatureC Min_TemperatureC
## 244 2016-08-31               32                28               24
## 245 2016-09-01               31                28               25
## 246 2016-09-02               31                28               24
## 247 2016-09-03               32                29               26
## 248 2016-09-04               30                28               27
# shows temperature for 3 days : Aug 1st 2016  to Aug 3 2016
getWeatherForDate(station_id, "2016-08-01", "2016-08-03")
## Retrieving from: http://www.wunderground.com/history/airport/SIN/2016/8/1/CustomHistory.html?dayend=3&monthend=8&yearend=2016&req_city=NA&req_state=NA&req_statename=NA&format=1
## The following columns are available:
##  [1] "SGT"                        "Max_TemperatureC"          
##  [3] "Mean_TemperatureC"          "Min_TemperatureC"          
##  [5] "Dew_PointC"                 "MeanDew_PointC"            
##  [7] "Min_DewpointC"              "Max_Humidity"              
##  [9] "Mean_Humidity"              "Min_Humidity"              
## [11] "Max_Sea_Level_PressurehPa"  "Mean_Sea_Level_PressurehPa"
## [13] "Min_Sea_Level_PressurehPa"  "Max_VisibilityKm"          
## [15] "Mean_VisibilityKm"          "Min_VisibilitykM"          
## [17] "Max_Wind_SpeedKm_h"         "Mean_Wind_SpeedKm_h"       
## [19] "Max_Gust_SpeedKm_h"         "Precipitationmm"           
## [21] "CloudCover"                 "Events"                    
## [23] "WindDirDegrees"
## Checking Summarized Data Availability For SIN
## Found 3 records for 2016-08-01 to 2016-08-03
## Data is Available for the interval.
## Will be fetching these Columns:
## [1] "Date"              "Max_TemperatureC"  "Mean_TemperatureC"
## [4] "Min_TemperatureC"
##         Date Max_TemperatureC Mean_TemperatureC Min_TemperatureC
## 1 2016-08-01               31                27               23
## 2 2016-08-02               32                28               23
## 3 2016-08-03               30                26               22

Graphs (in progress)