Created
May 8, 2014 11:24
-
-
Save bryanyang0528/eb7625288fb449efd1f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Data Source:http://www.cwb.gov.tw/V7/climate/dailyPrecipitation/dP.htm | |
#讀入檔案 | |
Kau_2011 <- as.matrix(read.csv("Kau_2011.csv",header=FALSE,fileEncoding="UTF-8-BOM")) | |
##Transform the row data(as matrix) to data frame type | |
#建立新的資料格式,只有兩欄,第一欄式日期,第二欄是雨量 | |
Kau_2011_N=matrix(nrow = 31*12, ncol = 2) | |
#建立一個計算變項,讓R知道等下要把數值填到哪一欄 | |
count <- 0 | |
#這邊使用雙重迴圈,分別代表月分和日期 | |
for (m in 1:12){ | |
for(i in 1:31){ | |
#Date | |
Kau_2011_N[i+count,1] <- paste("2011","/",m,"/",i,sep="") | |
#paste the data | |
Kau_2011_N[i+count,2] <- Kau_2011[i+1,m+1] | |
} | |
count <-count+31 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment