library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.5
#solar term
solar<-read.table("CalendarData.txt",header=TRUE,sep="")
solar_short<-subset(solar,select=c("yyyymmdd",'year',
"month","solar_term","solar_term_accu"))
#weather station id
weather_station<-read.table("WeatherStationData.txt",header=TRUE,sep="")
north_station<-subset(weather_station,area==1&altitude<100)
south_station<-subset(weather_station,area==3&altitude<100)
#weather data
weather_data<-read.table("RawWeatherData.txt",header=TRUE,sep="")
north_weather_data<-subset(weather_data,stno %in% north_station$stno)
south_weather_data<-subset(weather_data,stno %in% south_station$stno)
#combine north and south weather data
north_weather_data$area='north'
south_weather_data$area='south'
ns_weather_data<-rbind(north_weather_data,south_weather_data)
#combine the weather data and solar
ns_weather_data_solar<-merge(ns_weather_data,solar_short,by="yyyymmdd")
ns_weather_removed_data_solar<-ns_weather_data_solar[
round(ns_weather_data_solar$solar_term)==ns_weather_data_solar$solar_term,]
#change solar_term_accu
attach(ns_weather_removed_data_solar)
ns_weather_removed_data_solar$solar_term_accu<-(year-2000)*24+solar_term
#TX01
t<-ns_weather_removed_data_solar[ns_weather_removed_data_solar$TX01>0,]
###solar
tx01_solar<-aggregate(TX01~solar_term+area,
data=t,mean,na.rm=TRUE)
g<-ggplot(data=tx01_solar,aes(solar_term,TX01,colour=area))
g+geom_point(size=2,shape=21)+geom_line()+ylim(10,35)+
ggtitle('average temperature per solar_term')+
labs(y='average temperature')
###month
tx01_month<-aggregate(TX01~month+area,
data=t,mean,na.rm=TRUE)
g<-ggplot(data=tx01_month,aes(month,TX01,colour=area))
g+geom_point(size=2,shape=21)+geom_line()+ylim(10,35)+
ggtitle('average temperature per month')+
labs(y='average temperature')
#RH01
rh<-ns_weather_removed_data_solar[ns_weather_removed_data_solar$RH02>0,]
###solar
rh01_solar<-aggregate(RH02~solar_term+area,
data=rh,mean,na.rm=TRUE)
g<-ggplot(data=rh01_solar,aes(solar_term,RH02,colour=area))
g+geom_point(size=2,shape=21)+geom_line()+
ggtitle('relative humidity per solar_term')+
labs(y='relative humidity')
###month
rh01_month<-aggregate(RH02~month+area,
data=rh,mean,na.rm=TRUE)
g<-ggplot(data=rh01_month,aes(month,RH02,colour=area,fill=area))
g+geom_point(size=2,shape=21)+geom_line()+
ggtitle('relative humidity per month')+
labs(y='relative humidity')
##PP01
pp01<-ns_weather_removed_data_solar[ns_weather_removed_data_solar$PP01>0,]
###solar
pp01_solar<-aggregate(PP01~solar_term+area,
data=pp01,mean,na.rm=TRUE)
g<-ggplot(data=pp01_solar,aes(solar_term,PP01,colour=area))
g+geom_point(size=2,shape=21)+geom_line()+
ggtitle('avg Precipitation per solar_term')+
labs(y='avg Precipitation')
###month
pp01_month<-aggregate(PP01~month+area,
data=pp01,mean,na.rm=TRUE)
g<-ggplot(data=pp01_month,aes(factor(month),PP01,colour=area,fill=area))
g+geom_bar(stat='identity',position="dodge")+
ggtitle('avg Precipitation per month')+
labs(y='avg Precipitation')
0105,Slight cold,小寒
0120,Great cold,大寒
0204,Spring begins,立春
0219,The rains,雨水
0306,Insects awaken,驚蟄
0321,Vernal equinox,春分
0405,Clear and bright,清明
0420,Grain rain,穀雨
0506,Summer begins,立夏
0521,Grain buds,小滿
0606,Grain in ear,芒種
0621,Summer solstice,夏至
0707,Slight heat,小暑
0723,Great heat,大暑
0808,Autumn begins,立秋
0823,Stopping the heat,處暑
0908,White dews,白露
0923,Autumn equinox,秋分
1008,Cold dews,寒露
1023,Hoar-frost falls,霜降
1107,Winter begins,立冬
1122,Light snow,小雪
1207,Heavy snow,大雪
1222,Winter solstice,冬至
plot month & solar term 芒種下降, 小暑上升
taipei_ad<-read.table('ad_taipei_mo',header=FALSE,sep=" ")
names(taipei_ad)<-c('id','sex','date','area')
taipei_ad$num=1
#by date
taipei_ad_day<-aggregate(data=taipei_ad,num~date,sum,na.rm=TRUE)
taipei_ad_day$date<-as.Date(taipei_ad_day$date,formtat='%Y-%m-%d')
#remove 1999 ,from 2000-01-01 to 2010-12-31
taipei_ad_day=taipei_ad_day[taipei_ad_day$date>=as.Date('2000-01-01'),]
#set solar date format
solar$date<-paste(as.character(solar$year),
"-",as.character(solar$month),
"-",as.character(solar$day),sep="")
solar$date=as.Date(solar$date,format='%Y-%m-%d')
solar_short1<-subset(solar,select=c("date",'year',
"month","solar_term","solar_term_accu"))
#combine the ad data and solar=>complete
taipei_ad_day1<-merge(solar_short1,taipei_ad_day,by='date')
taipei_ad_day_remove<-taipei_ad_day1[
round(taipei_ad_day1$solar_term)==taipei_ad_day1$solar_term,]
#change acc_solar
attach(taipei_ad_day_remove)
## The following objects are masked from ns_weather_removed_data_solar:
##
## month, solar_term, solar_term_accu, year
taipei_ad_day_remove$solar_term_accu<-(year-2000)*24+solar_term
###solar
ad_solar<-aggregate(num~solar_term,
data=taipei_ad_day_remove,mean,na.rm=TRUE)
g<-ggplot(data=ad_solar,aes(solar_term,num))
g+geom_point(size=4,shape=20,colour='red')+geom_line(colour='blue')+
ylim(20,55)+
ggtitle('atopic dermatitis per solar_term')+
labs(y='atopic dermatitis')
###month
ad_month<-aggregate(num~month,
data=taipei_ad_day_remove,mean,na.rm=TRUE)
g<-ggplot(data=ad_month,aes(month,num))
g+geom_point(size=4,shape=20,colour='red')+geom_line(colour='blue')+
ylim(20,55)+
ggtitle('atopic dermatitis per month')+
labs(y='atopic dermatitis')
11th solar term is nadir and 13th solar term is peak
芒種下降, 小暑上升
north_ad<-read.table('ad_north_mo',header=FALSE,sep=" ")
names(north_ad)<-c('id','sex','date','area')
north_ad$num=1
#by date
north_ad_day<-aggregate(data=north_ad,num~date,sum,na.rm=TRUE)
north_ad_day$date<-as.Date(north_ad_day$date,formtat='%Y-%m-%d')
#remove 1999 ,from 2000-01-01 to 2010-12-31
north_ad_day=north_ad_day[north_ad_day$date>=as.Date('2000-01-01'),]
#combine the ad data and solar=>complete
north_ad_day1<-merge(solar_short1,north_ad_day,by='date')
north_ad_day_remove<-north_ad_day1[
round(north_ad_day1$solar_term)==north_ad_day1$solar_term,]
#test
table(north_ad_day_remove$solar_term)
##
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## 158 158 158 159 165 165 165 165 165 165 165 165 165 165 165 165 164 164
## 19 20 21 22 23 24
## 165 165 165 163 159 161
##ad
#change acc_solar
attach(north_ad_day_remove)
## The following objects are masked from taipei_ad_day_remove:
##
## date, month, num, solar_term, solar_term_accu, year
## The following objects are masked from ns_weather_removed_data_solar:
##
## month, solar_term, solar_term_accu, year
north_ad_day_remove$solar_term_accu<-(year-2000)*24+solar_term
###solar
north_ad_solar<-aggregate(num~solar_term,
data=north_ad_day_remove,mean,na.rm=TRUE)
g<-ggplot(data=north_ad_solar,aes(solar_term,num))
g+geom_point(size=4,shape=20,colour='red')+geom_line(colour='blue')+
ylim(20,55)+
ggtitle('atopic dermatitis per solar_term in north')+
labs(y='atopic dermatitis')
###month
north_ad_month<-aggregate(num~month,
data=north_ad_day_remove,mean,na.rm=TRUE)
g<-ggplot(data=north_ad_month,aes(month,num))
g+geom_point(size=4,shape=20,colour='red')+geom_line(colour='blue')+
ylim(20,55)+
ggtitle('atopic dermatitis per month in north')+
labs(y='atopic dermatitis')
芒種下降, 小暑上升
south_ad<-read.table('ad_south_mo',header=FALSE,sep=" ")
names(south_ad)<-c('id','sex','date','area')
south_ad$num=1
#by date
south_ad_day<-aggregate(data=south_ad,num~date,sum,na.rm=TRUE)
south_ad_day$date<-as.Date(south_ad_day$date,formtat='%Y-%m-%d')
#remove 1999 ,from 2000-01-01 to 2010-12-31
south_ad_day=south_ad_day[south_ad_day$date>=as.Date('2000-01-01'),]
#test
min(south_ad_day$date)
## [1] "2000-01-01"
#combine the ad data and solar=>complete
south_ad_day1<-merge(solar_short1,south_ad_day,by='date')
south_ad_day_remove<-south_ad_day1[
round(south_ad_day1$solar_term)==south_ad_day1$solar_term,]
#test
table(south_ad_day_remove$solar_term)
##
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## 157 158 155 160 164 164 164 163 165 165 165 164 165 164 165 165 165 163
## 19 20 21 22 23 24
## 165 165 165 163 160 161
##ad
#change acc_solar
attach(south_ad_day_remove)
## The following objects are masked from north_ad_day_remove:
##
## date, month, num, solar_term, solar_term_accu, year
## The following objects are masked from taipei_ad_day_remove:
##
## date, month, num, solar_term, solar_term_accu, year
## The following objects are masked from ns_weather_removed_data_solar:
##
## month, solar_term, solar_term_accu, year
south_ad_day_remove$solar_term_accu<-(year-2000)*24+solar_term
###solar
south_ad_solar<-aggregate(num~solar_term,
data=south_ad_day_remove,mean,na.rm=TRUE)
g<-ggplot(data=south_ad_solar,aes(solar_term,num))
g+geom_point(size=4,shape=20,colour='red')+geom_line(colour='blue')+
ylim(20,55)+
ggtitle('atopic dermatitis per solar_term in south')+
labs(y='atopic dermatitis')
###month
south_ad_month<-aggregate(num~month,
data=south_ad_day_remove,mean,na.rm=TRUE)
g<-ggplot(data=south_ad_month,aes(month,num))
g+geom_point(size=4,shape=20,colour='red')+geom_line(colour='blue')+
ylim(20,55)+
ggtitle('atopic dermatitis per month in south')+
labs(y='atopic dermatitis')
##the eather data detail
TX01 平均氣溫(℃)
TX02 最高氣溫(℃)
TX03 最高氣溫時間
TX04 最低氣溫(℃)
TX05 最低氣溫時間
TX06 平均露點溫度(℃)
TX07 平均濕球氣溫(℃)
TX08 黑球溫度(℃)
TX09 氣溫日較差(℃)
RH 相對濕度
RH02 最大相對濕度(%)
RH04 最小相對濕度(%)
PP 降水
PP01 降水量(mm)
PP02 降水時數(hr)
PP03 十分鐘最大降水量(mm)
PP05 一小時最大降水量(mm)
This is for north
We found that 9th is peak and 11th is nadir totally in North and South
Also,there are the same pattern in 2005,2006,2008,2009 and 2010 in North
Besides,there are the same pattern in 2002,2004,2005,2006,2008,2009 and 2010 in South
#North each year plot
north_ad_solar1<-aggregate(num~solar_term+year,
data=north_ad_day_remove,mean,na.rm=TRUE)
north_ad_solar_total<-aggregate(num~solar_term,
data=north_ad_solar1,sum,na.rm=TRUE)
ggplot(data=north_ad_solar_total,aes(solar_term,num))+geom_point()+geom_line()
11th is nadir
ggplot(data=north_ad_solar1[1:72,],aes(solar_term,num,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=north_ad_solar1[73:144,],aes(solar_term,num,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=north_ad_solar1[145:216,],aes(solar_term,num,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=north_ad_solar1[217:264,],aes(solar_term,num,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
#South each year plot
south_ad_solar1<-aggregate(num~solar_term+year,
data=south_ad_day_remove,mean,na.rm=TRUE)
south_ad_solar_total<-aggregate(num~solar_term,
data=south_ad_solar1,sum,na.rm=TRUE)
ggplot(data=south_ad_solar_total,aes(solar_term,num))+geom_point()+geom_line()
This is for South
#South each year plot
ggplot(data=south_ad_solar1[1:72,],aes(solar_term,num,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=south_ad_solar1[73:144,],aes(solar_term,num,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=south_ad_solar1[145:216,],aes(solar_term,num,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=south_ad_solar1[217:264,],aes(solar_term,num,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
平均氣溫
In 2010, the TX01 decreases in 11th in North
In 2006,2009 and 2010, the TX01 decreases in 11th in South
PS:there are the number for AD decreasing in 2005,2006,2008,2009 and 2010 in North
Besides,there are the same pattern for AD in 2002,2004,2005,2006,2008,2009 and 2010 in South
It seems that the avg Temperature would predict the AD
tx01<-subset(t,,select=c(TX01,solar_term_accu,solar_term,area,year))
tx02<-aggregate(TX01~solar_term+area+year,
data=tx01,mean,na.rm=TRUE)
n_tx02<-subset(tx02,area=='north')
s_tx02<-subset(tx02,area=='south')
In North
#North for ploting
ggplot(data=n_tx02[1:72,],aes(solar_term,TX01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_tx02[73:144,],aes(solar_term,TX01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_tx02[145:216,],aes(solar_term,TX01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_tx02[217:264,],aes(solar_term,TX01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
In South
#South for ploting
ggplot(data=s_tx02[1:72,],aes(solar_term,TX01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_tx02[73:144,],aes(solar_term,TX01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_tx02[145:216,],aes(solar_term,TX01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_tx02[217:264,],aes(solar_term,TX01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
RH02 最大相對濕度(%)
In 2001,2004 and 2005 and 2009, the RH02 decreases in 11th in North
In 2001 and 2004, the RH02 decreases in 11th in South
PS:there are the number for AD decreasing in 2005,2006,2008 and 2010 in North
Besides,there are the same pattern for AD in 2002,2004,2005,2006,2008,2009 and 2010 in South
_It seems RH would not have power to predict AD__
rh01<-subset(rh,,select=c(RH02,solar_term_accu,solar_term,area,year))
rh02<-aggregate(RH02~solar_term+area+year,
data=rh01,mean,na.rm=TRUE)
n_rh02<-subset(rh02,area=='north')
s_rh02<-subset(rh02,area=='south')
In North
#North for ploting
ggplot(data=n_rh02[1:72,],aes(solar_term,RH02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_rh02[73:144,],aes(solar_term,RH02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_rh02[145:216,],aes(solar_term,RH02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_rh02[217:264,],aes(solar_term,RH02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
In South
#South for ploting
ggplot(data=s_rh02[1:72,],aes(solar_term,RH02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_rh02[73:144,],aes(solar_term,RH02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_rh02[145:216,],aes(solar_term,RH02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_rh02[217:264,],aes(solar_term,RH02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
PP01 降水量(mm)
PP02 降水時數(hr)
PP03 十分鐘最大降水量(mm)
PP05 一小時最大降水量(mm)
The PP01 decreases in 11th in North in 2004 and 2005 while it decreases in South in 2001 ,2002 and 2004
The PP02 decreases in 11th in North in 2001,2004,2005 while it decreases in South in 2000,2001,2004,2009 and 2010
The PP03 does not decrease in North while it decreases in South in 2001,2002,2004,2010
The PP05 does not decrease in North while it decreases in South in 2001,2002,2004
PS:there are the number for AD decreasing in 2005,2006,2008,2009 and 2010 in North
Besides,there are the same pattern for AD in 2002,2004,2005,2006,2008,2009 and 2010 in South
pp<-ns_weather_removed_data_solar[ns_weather_removed_data_solar$PP01>0&ns_weather_removed_data_solar$PP02>0&ns_weather_removed_data_solar$PP03>0,]
pp1<-subset(pp,,select=c(PP01,PP02,PP03,PP05,
solar_term_accu,solar_term,area,year))
pp2<-aggregate(cbind(PP01,PP02,PP03,PP05)~solar_term+area+year,
data=pp1,mean,na.rm=TRUE)
n_pp2<-subset(pp2,area=='north')
s_pp2<-subset(pp2,area=='south')
The PP01 decreases in 11th in North in 2004 and 2005 while it decreases in South in 2001 ,2002 and 2004
降水量 In North
pp<-ns_weather_removed_data_solar[ns_weather_removed_data_solar$PP01>0,]
pp01<-subset(pp,,select=c(PP01,solar_term_accu,solar_term,area,year))
pp02<-aggregate(PP01~solar_term+area+year,
data=pp01,mean,na.rm=TRUE)
n_pp21<-subset(pp02,area=='north')
s_pp21<-subset(pp02,area=='south')
#North for ploting for PP01
ggplot(data=n_pp21[1:72,],aes(solar_term,PP01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp21[73:144,],aes(solar_term,PP01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp21[145:216,],aes(solar_term,PP01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp21[217:264,],aes(solar_term,PP01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
降水量 In South
#South for ploting for PP01
ggplot(data=s_pp21[1:72,],aes(solar_term,PP01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp21[73:144,],aes(solar_term,PP01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp21[145:216,],aes(solar_term,PP01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp21[217:264,],aes(solar_term,PP01,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
## Warning: Removed 10 rows containing missing values (geom_point).
The PP02 decreases in 11th in North in 2001,2004,2005 while it decreases in South in 2000,2001,2004,2009 and 2010
降水時數 In North
pp<-ns_weather_removed_data_solar[ns_weather_removed_data_solar$PP02>0,]
pp01<-subset(pp,,select=c(PP02,solar_term_accu,solar_term,area,year))
pp02<-aggregate(PP02~solar_term+area+year,
data=pp01,mean,na.rm=TRUE)
n_pp22<-subset(pp02,area=='north')
s_pp22<-subset(pp02,area=='south')
#North for ploting for PP02
ggplot(data=n_pp22[1:72,],aes(solar_term,PP02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp22[73:144,],aes(solar_term,PP02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp22[145:216,],aes(solar_term,PP02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp22[217:264,],aes(solar_term,PP02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
降水時數 In South
#South for ploting for PP02
ggplot(data=s_pp22[1:72,],aes(solar_term,PP02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
## geom_path: Each group consists of only one observation. Do you need to
## adjust the group aesthetic?
ggplot(data=s_pp22[73:144,],aes(solar_term,PP02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp22[145:216,],aes(solar_term,PP02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp22[217:264,],aes(solar_term,PP02,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
## Warning: Removed 4 rows containing missing values (geom_point).
The PP03 does not decrease in North while it decreases in South in 2001,2002,2004,2010
十分鐘最大降水量 In North
pp<-ns_weather_removed_data_solar[ns_weather_removed_data_solar$PP03>0,]
pp01<-subset(pp,,select=c(PP03,solar_term_accu,solar_term,area,year))
pp02<-aggregate(PP03~solar_term+area+year,
data=pp01,mean,na.rm=TRUE)
n_pp23<-subset(pp02,area=='north')
s_pp23<-subset(pp02,area=='south')
#North for ploting for PP02
ggplot(data=n_pp23[1:72,],aes(solar_term,PP03,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp23[73:144,],aes(solar_term,PP03,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp23[145:216,],aes(solar_term,PP03,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp23[217:264,],aes(solar_term,PP03,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
十分鐘最大降水量 In South
#South for ploting for PP02
ggplot(data=s_pp23[1:72,],aes(solar_term,PP03,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp23[73:144,],aes(solar_term,PP03,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp23[145:216,],aes(solar_term,PP03,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp23[217:264,],aes(solar_term,PP03,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
## Warning: Removed 10 rows containing missing values (geom_point).
The PP05 does not decrease in North while it decreases in South in 2001,2002,2004
一小時最大降水量 In North
pp<-ns_weather_removed_data_solar[ns_weather_removed_data_solar$PP05>0,]
pp01<-subset(pp,,select=c(PP05,solar_term_accu,solar_term,area,year))
pp02<-aggregate(PP05~solar_term+area+year,
data=pp01,mean,na.rm=TRUE)
n_pp25<-subset(pp02,area=='north')
s_pp25<-subset(pp02,area=='south')
#North for ploting for PP02
ggplot(data=n_pp25[1:72,],aes(solar_term,PP05,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp25[73:144,],aes(solar_term,PP05,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp25[145:216,],aes(solar_term,PP05,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=n_pp25[217:264,],aes(solar_term,PP05,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
一小時最大降水量 In South
#South for ploting for PP02
ggplot(data=s_pp25[1:72,],aes(solar_term,PP05,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp25[73:144,],aes(solar_term,PP05,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp25[145:216,],aes(solar_term,PP05,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
ggplot(data=s_pp25[217:264,],aes(solar_term,PP05,colour=as.factor(year)))+geom_point()+geom_line()+facet_grid(year~.)
## Warning: Removed 10 rows containing missing values (geom_point).
library(e1071)
## Warning: package 'e1071' was built under R version 3.2.5
rh<-ns_weather_removed_data_solar[ns_weather_removed_data_solar$RH04>0,]
rh01_solar<-aggregate(RH04~solar_term+area,
data=rh,mean,na.rm=TRUE)
rh01<-subset(rh,,select=c(RH04,solar_term_accu,solar_term,area,year))
rh02<-aggregate(RH04~solar_term+area+year,
data=rh01,mean,na.rm=TRUE)
n_rh04<-subset(rh02,area=='north')
s_rh04<-subset(rh02,area=='south')
###
north_ad<-north_ad_solar1[north_ad_solar1$solar_term %in% c(9,10,11),]
south_ad<-south_ad_solar1[south_ad_solar1$solar_term %in% c(9,10,11),]
n_tx<-n_tx02[n_tx02$solar_term %in% c(9,10,11),]
s_tx<-s_tx02[s_tx02$solar_term %in% c(9,10,11),]
n_rhmax<-n_rh02[n_rh02$solar_term %in% c(9,10,11),]
s_rhmax<-s_rh02[s_rh02$solar_term %in% c(9,10,11),]
n_rhmin<-n_rh04[n_rh04$solar_term %in% c(9,10,11),]
s_rhmin<-s_rh04[s_rh04$solar_term %in% c(9,10,11),]
n_pp_total<-n_pp21[n_pp21$solar_term %in% c(9,10,11),]
s_pp_total<-s_pp21[s_pp21$solar_term %in% c(9,10,11),]
n_pp_hr<-n_pp22[n_pp22$solar_term %in% c(9,10,11),]
s_pp_hr<-s_pp22[s_pp22$solar_term %in% c(9,10,11),]
n_pp_10min<-n_pp23[n_pp23$solar_term %in% c(9,10,11),]
s_pp_10min<-s_pp23[s_pp23$solar_term %in% c(9,10,11),]
n_pp_1hr<-n_pp25[n_pp25$solar_term %in% c(9,10,11),]
s_pp_1hr<-s_pp25[s_pp25$solar_term %in% c(9,10,11),]
##combine
length(n_pp_1hr$PP05)
## [1] 33
nx<-cbind(north_ad$solar_term,north_ad$year,north_ad$num,
n_tx$TX,n_rhmax$RH02,n_rhmin$RH04,n_pp_total$PP01,
n_pp_hr$PP02,n_pp_10min$PP03,n_pp_1hr$PP05)
nx<-data.frame(nx)
names(nx)<-c('solar_term','year','num','TX','rhmax','rhmin',
'pp_total','pp_hr','pp_10min','pp_1hr')
north_fit<-lm(num~TX+rhmax+rhmin+pp_total+pp_hr+pp_10min+pp_1hr,data=nx)
summary(north_fit)
##
## Call:
## lm(formula = num ~ TX + rhmax + rhmin + pp_total + pp_hr + pp_10min +
## pp_1hr, data = nx)
##
## Residuals:
## Min 1Q Median 3Q Max
## -12.2359 -5.5965 -0.4763 4.0662 14.2874
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 190.4785 61.9084 3.077 0.00502 **
## TX -3.3401 2.0440 -1.634 0.11477
## rhmax -1.3156 0.7336 -1.793 0.08501 .
## rhmin 0.8751 0.5480 1.597 0.12284
## pp_total 0.1067 0.5714 0.187 0.85335
## pp_hr -2.4315 1.4876 -1.635 0.11467
## pp_10min 1.6046 4.4921 0.357 0.72394
## pp_1hr 1.4806 2.0937 0.707 0.48601
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.064 on 25 degrees of freedom
## Multiple R-squared: 0.3264, Adjusted R-squared: 0.1379
## F-statistic: 1.731 on 7 and 25 DF, p-value: 0.1472
##south
sx<-cbind(south_ad$solar_term,south_ad$year,south_ad$num,
s_tx$TX,s_rhmax$RH02,s_rhmin$RH04,s_pp_total$PP01,
s_pp_hr$PP02,s_pp_10min$PP03,s_pp_1hr$PP05)
sx<-data.frame(sx)
names(sx)<-c('solar_term','year','num','TX','rhmax','rhmin',
'pp_total','pp_hr','pp_10min','pp_1hr')
south_fit<-lm(num~TX+rhmax+rhmin+pp_total+pp_hr+pp_10min+pp_1hr,data=sx)
summary(south_fit)
##
## Call:
## lm(formula = num ~ TX + rhmax + rhmin + pp_total + pp_hr + pp_10min +
## pp_1hr, data = sx)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.881 -1.448 -0.075 2.212 6.012
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -26.550857 24.329727 -1.091 0.286
## TX 0.903543 0.876778 1.031 0.313
## rhmax 0.339130 0.304468 1.114 0.276
## rhmin -0.002708 0.229596 -0.012 0.991
## pp_total -0.188898 0.178404 -1.059 0.300
## pp_hr -1.006291 0.759560 -1.325 0.197
## pp_10min 0.665478 1.334354 0.499 0.622
## pp_1hr 0.288923 0.823558 0.351 0.729
##
## Residual standard error: 3.041 on 25 degrees of freedom
## Multiple R-squared: 0.4289, Adjusted R-squared: 0.269
## F-statistic: 2.682 on 7 and 25 DF, p-value: 0.03232