Importing the data set
library(readr)
slemsa_ca <- read_csv("~/soil loss/slemsa_ca.csv")
## Parsed with column specification:
## cols(
## Country = col_character(),
## Site = col_character(),
## Agroeco = col_character(),
## Farmer_Name = col_character(),
## Drainage_class = col_character(),
## Season = col_character(),
## Treatment = col_double(),
## Treatment_description = col_character(),
## System = col_character(),
## Cropping_Systems = col_character(),
## Intercepted = col_double(),
## Crop_Canopy = col_double(),
## Seasonal_rainfall_energy = col_double(),
## Erodability_Factor = col_double(),
## Topographic_ratio = col_double(),
## Soil_loss = col_double(),
## Residue_cover = col_double(),
## rainfall = col_double(),
## slope = col_double()
## )
View(slemsa_ca)
attach(slemsa_ca)
Defining th factor variables
Country=as.factor(Country)
Site=as.factor(Site)
Farmer_Name=as.factor(Farmer_Name)
Agroeco=as.factor(Agroeco)
Season=as.factor(Season)
Drainage_class=as.factor(Drainage_class)
Treatment=as.factor(Treatment)
Treatment_description=as.factor(Treatment_description)
System=as.factor(System)
Cropping_Systems=as.factor(Cropping_Systems)
Loading the required packages
library(ggplot2)
library(maps)
library(ggalt)
library(extrafontdb)
library(MASS)
library(pscl)
## Classes and Methods for R developed in the
## Political Science Computational Laboratory
## Department of Political Science
## Stanford University
## Simon Jackman
## hurdle and zeroinfl functions by Achim Zeileis
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library(gridExtra)
describeBy(Soil_loss,Cropping_Systems)
##
## Descriptive statistics by group
## group: CA_INT
## vars n mean sd median trimmed mad min max range skew kurtosis
## X1 1 300 0.72 1.23 0.44 0.54 0.32 0 17.3 17.3 9.47 115.36
## se
## X1 0.07
## --------------------------------------------------------
## group: CA_ROT
## vars n mean sd median trimmed mad min max range skew kurtosis
## X1 1 610 1.94 2.98 0.81 1.27 0.92 0 23.72 23.72 3.3 13.55
## se
## X1 0.12
## --------------------------------------------------------
## group: CA_SOLE
## vars n mean sd median trimmed mad min max range skew kurtosis
## X1 1 544 2.07 3.14 0.93 1.37 1.11 0 29.31 29.31 3.45 16.97
## se
## X1 0.13
Plots
theme_set(theme_gray(base_size = 14))
ggplot(data=slemsa_ca,aes(x=Cropping_Systems,y=Soil_loss,color=Country))+
geom_boxplot(outlier.size=0,width=0.5,shape=20)+xlab("CA Cropping Systems")+ylab("Soil Loss [t/ha]")+theme(legend.position = c(0.82, 0.84))
theme_set(theme_gray(base_size = 14))
ggplot(data=slemsa_ca,aes(x=Cropping_Systems,y=Soil_loss,color=Country))+ geom_boxplot(outlier.size=0,width=0.5,shape=20)+facet_grid(Agroeco~.)+xlab("CA Cropping Systems")+ylab("Soil Loss [t/ha]")+
theme(legend.position = c(0.82, 0.84))
Soil loss and rainfall intercepted
#soil loss and rainfall intercepted
theme_set(theme_gray(base_size = 14))
p <- ggplot(data=slemsa_ca,aes(y=Soil_loss,x=Intercepted, color=Agroeco))
p + geom_smooth()+xlab("Rainfall Intercepted [i(%)]")+ylab("Soil Loss [t/ha]")+
theme(legend.position = c(0.82, 0.84))
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'