Your SlideShare is downloading. ×
111130 r lecture_presentation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

111130 r lecture_presentation

1,414
views

Published on

研究室内で行ったR講習会のプレゼンファイル

研究室内で行ったR講習会のプレゼンファイル

Published in: Technology, Career

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,414
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. R (NetCDF) R Takayuki NUIMURA 30th Nov. 2011Takayuki NUIMURA R
  • 2. R (NetCDF)Outline 1 R 2 3 4 (NetCDF) Takayuki NUIMURA R
  • 3. R (NetCDF)R Takayuki NUIMURA R
  • 4. R (NetCDF)R R Windows R Linux R ( ) R > q() # No OK Takayuki NUIMURA R
  • 5. R (NetCDF)>2+3[1] 5>2ˆ8[1] 256> temp.dc <- 10> temp.dc[1] 10> temp.df <- 9 / 5 * temp.dc + 32> temp.df[1] 50 Takayuki NUIMURA R
  • 6. R (NetCDF) (plot )1> temp <- c(10, 20, 15, 25, 20, 20)> plot(temp) 25 20 temp 15 10 1 2 3 4 5 6 Index Takayuki NUIMURA R
  • 7. R (NetCDF) (plot )2> year <- c(2000, 2004, 2005, 2007, 2010, 2011)> plot(year, temp) 25 20 temp 15 10 2000 2002 2004 2006 2008 2010 year Takayuki NUIMURA R
  • 8. R (NetCDF) (plot )2> year <- c(2000, 2004, 2005, 2007, 2010, 2011)> plot(year, temp, type=“l”, col=“red”, xlim=c(1990, 2020),ylim=c(0, 30)) 30 25 20 temp 15 10 5 0 1990 1995 2000 2005 2010 2015 2020 year Takayuki NUIMURA R
  • 9. R (NetCDF) (histogram )> hist(temp) Histogram of temp 3.0 2.5 2.0 Frequency 1.5 1.0 0.5 0.0 10 15 20 25 temp Takayuki NUIMURA R
  • 10. R (NetCDF) (histogram )> hist(rnorm(10000)) Histogram of rnorm(10000) 1500 Frequency 1000 500 0 −4 −2 0 2 4 rnorm(10000) Takayuki NUIMURA R
  • 11. R (NetCDF) (histogram )> hist(rnorm(10000), col=“lightblue”, breaks=100) Histogram of rnorm(10000) 400 300 Frequency 200 100 0 −2 0 2 4 rnorm(10000) Takayuki NUIMURA R
  • 12. R (NetCDF)R xls csv csv txt csv dbf GIS GeoTiff Shapefile GIS NetCDF Takayuki NUIMURA R
  • 13. R (NetCDF)CSV # Windows: C r_lecture > setwd(“C:/r_lecture”) # Ubuntu: /home/username/r_lecture > setwd(“/home/username/r_lecture”) read.csv # (2001–2010) > temp <- read.csv(“nagoya_temp.csv”) Takayuki NUIMURA R
  • 14. R (NetCDF)CSV matrix 2 > temp.matrix <- matrix(temp[,2], 10, 12, byrow=T) # dim > dim(temp.matrix) [1] 10 12 Takayuki NUIMURA R
  • 15. R (NetCDF)CSV 2 # > colnames(temp.matrix) <- 1:12 # > rownames(temp.matrix) <- 2001:2010 2 CSV > write.csv(temp.matrix, “temp_matrix.csv”) Takayuki NUIMURA R
  • 16. R (NetCDF)NetCDF RNetCDF # > library(RNetCDF) # 5◦ # 1850 Jan.–2011 Oct. > nc <- open.nc(“CRUTEM3.nc”) > nc.data <- var.get.nc(nc, “temp”) # dim > dim(nc.data) [1] 72 36 1942 (W180⇒E180) (S90⇒N90) (1850 160 ×12 + 10) Takayuki NUIMURA R
  • 17. R (NetCDF)2 apply # > apply(temp.matrix, 1, mean) # > apply(temp.matrix, 2, mean) mean sum max min sd summary Takayuki NUIMURA R
  • 18. R (NetCDF)t t.test # 2001 2010 > t.test(temp.matrix[1,], temp.matrix[10,]) t = -0.1723, df = 22, p-value < 0.8648 # 2001 2010 # 2001–2010 1 2 > t.test(temp.matrix[,1], temp.matrix[,2]) t = -3.1955, df = 15.935, p-value < 0.005654 #1 2 Takayuki NUIMURA R
  • 19. R (NetCDF)cor.test# 2001 2010> cor.test(temp.matrix[1,], temp.matrix[10,])t = 22.804, df = 10, p-value < 5.93e-10cor 0.9905215# 0.99 Takayuki NUIMURA R
  • 20. R (NetCDF) DownloadDownload Download Download Takayuki NUIMURA R
  • 21. R (NetCDF)#2# temp.matrix 2003–2006> temp.matrix[3:6,]# 6–9> temp.matrix[3:6, 6:9]3 (x, y, time)matrix[x ,y , time ] Takayuki NUIMURA R
  • 22. R (NetCDF)meanRange.r meanRange.r 1 (1850–2011) 2 3 NetCDF 4 JJAS 5 Download Takayuki NUIMURA R
  • 23. R (NetCDF) corGlobal.r1 (1850–2011)23 NetCDF4 JJAS5 (CSV)67Download Takayuki NUIMURA R
  • 24. R (NetCDF)500−50 −150 −100 −50 0 50 100 150 Takayuki NUIMURA R