[R] How to calculate the statistcs for extracted region?
Jonsson
amen.alyaari at Bordeaux.inra.fr
Wed Jun 13 18:55:35 CEST 2012
I have a binary file(a) with size of (360 720 )for the globe.I wrote the code
given below to read and extract an area (south america)from that file. when
I use summary for the whole file I got:
summary(a, na.rm=FALSE)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
0.00 1.00 3.00 4.15 7.00 20.00 200083 .
But when I used summary for the region(b) which I extracted, I got many
V1,V2, V3. Which is not right I should have got one line (as for a )not many
V1,V2.
Here is the code:
X <- c(200:300)
Y <- c(150:190)
conne <- file("C:\\initial-WTD.bin", "rb")
a=readBin(conne, numeric(), size=4, n=360*720, signed=TRUE)
a[a == -9999] <- NA
y <- matrix(data=a,ncol=360,nrow=720)
image(t(t(y[X,Y])),ylim=c(1,0))
b = y[X,Y]
summary(b,na.rm=TRUE)
V1 V2 V3 V4 V5 V6
V7
Min. : 1.000 Min. : 1.000 Min. : 1.000 Min. : 1.000
Min. : 0.000 Min. : 0.000
1st Qu.: 4.000 1st Qu.: 4.000 1st Qu.: 4.000 1st Qu.: 3.000 1st
Qu.: 2.000 1st Qu.: 2.000
Median : 5.000 Median : 6.000 Median : 5.000 Median : 5.000 Median
: 5.000 Median : 5.000
Mean : 5.808 Mean : 5.962 Mean : 5.506 Mean : 4.946 Mean
: 5.068 Mean : 4.829
3rd Qu.: 6.750 3rd Qu.: 7.000 3rd Qu.: 7.000 3rd Qu.: 6.000 3rd
Qu.: 7.000 3rd Qu.: 6.000
Max. :18.000 Max. :19.000 Max. :17.000 Max. :13.000 Max.
:19.000 Max. :18.000
--
View this message in context: http://r.789695.n4.nabble.com/How-to-calculate-the-statistcs-for-extracted-region-tp4633295.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list