Import the climate dataset

#Let R to read the dataset
dat1=read.csv("C:/VAN's/climate dat.csv")
head(dat1)
##   STATION ECOSYS     BIOME  MAT MWMT  MCMT MAP MSP DRYNESS
## 1  300114   G-NF Grassland  2.4 17.5 -24.9 443 287      17
## 2  301449  G-DMG Grassland  4.5 18.8 -23.1 415 257       3
## 3  302343   G-MG Grassland  4.9 18.4 -23.3 429 258      12
## 4  302369  G-DMG Grassland  5.1 18.3 -24.3 405 254       1
## 5  302789   G-NF Grassland  2.8 17.4 -22.2 431 291      14
## 6  304155   B-AP    Boreal -0.9 17.4 -30.4 480 292      45
attach(dat1)
BIOMED=as.factor(BIOME)
ECOSYS=as.factor(ECOSYS)
str(BIOME)
##  chr [1:126] "Grassland" "Grassland" "Grassland" "Grassland" "Grassland" ...
str(ECOSYS)
##  Factor w/ 21 levels "B-AP","B-BSA",..: 16 12 15 12 16 1 11 19 4 6 ...

#Histogram

#Histogram
par(mfrow=c(2,2))
hist(DRYNESS,col="purple",breaks=7)
hist(log(DRYNESS),col="orange",breaks=7)
hist(DRYNESS^2,col="blue",breaks=7)
hist(sqrt(DRYNESS),col="red",breaks=8)

#Box

#Boxplot
boxplot(MWMT,col="yellow",ylab="Temperature, oc")

#plot multiple boxplots
boxplot(MAT,MWMT,MCMT, names=c("MAT","MWMT","MCMT"),ylab="Temperature, oc", xlab="Climate variable",col=c("purple","brown","red"))

#Boxplots by group
boxplot(MAT~BIOMED)

#A

#Scatter plot
plot(MSP~MAP,col="pink",xlab="Mean Annual Precipitation (mm)",ylab="Mean Summer Precipitation (mm)")

#Create multiple scatter plots of among MAT,MAP,MSP,DRYNESS variables
plot(dat1[,c("MAT","MAP","MSP","DRYNESS")])

#Numberical statistics

library(plyr)
mean(MAT)
## [1] 1.231746
summary(dat1)
##     STATION          ECOSYS             BIOME                MAT        
##  Min.   :300114   Length:126         Length:126         Min.   :-4.400  
##  1st Qu.:321198   Class :character   Class :character   1st Qu.:-0.850  
##  Median :340586   Mode  :character   Mode  :character   Median : 1.400  
##  Mean   :346145                                         Mean   : 1.232  
##  3rd Qu.:369304                                         3rd Qu.: 3.175  
##  Max.   :397981                                         Max.   : 6.900  
##       MWMT            MCMT             MAP             MSP       
##  Min.   :11.70   Min.   :-33.30   Min.   :402.0   Min.   :249.0  
##  1st Qu.:15.60   1st Qu.:-29.00   1st Qu.:454.5   1st Qu.:278.0  
##  Median :16.50   Median :-24.80   Median :489.0   Median :302.0  
##  Mean   :16.32   Mean   :-25.75   Mean   :503.1   Mean   :301.5  
##  3rd Qu.:17.38   3rd Qu.:-22.70   3rd Qu.:529.0   3rd Qu.:316.8  
##  Max.   :18.90   Max.   :-20.10   Max.   :738.0   Max.   :370.0  
##     DRYNESS      
##  Min.   :  1.00  
##  1st Qu.: 24.50  
##  Median : 37.00  
##  Mean   : 39.76  
##  3rd Qu.: 52.00  
##  Max.   :130.00
ddply(dat1,.(BIOMED),summarise,mMAT=mean(MAT))
##      BIOMED       mMAT
## 1    Boreal -0.2939394
## 2 Grassland  4.4516129
## 3   Montane  1.2620690
ddply(dat1,.(BIOMED),summarise,mMAT=mean(MAT),sdMAT=sd(MAT))
##      BIOMED       mMAT    sdMAT
## 1    Boreal -0.2939394 1.988496
## 2 Grassland  4.4516129 1.327622
## 3   Montane  1.2620690 1.857882