ICAR Research Complex for NEH Region

Umiam, Meghalaya

Library Required Packages

library(readxl)
## Warning: package 'readxl' was built under R version 4.5.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.5.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.3
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.5.3
## corrplot 0.95 loaded
library(GGally)
## Warning: package 'GGally' was built under R version 4.5.3
library(psych)
## Warning: package 'psych' was built under R version 4.5.3
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
library(knitr)
## Warning: package 'knitr' was built under R version 4.5.3

Import Data

Datanew <- read_excel("cropdata.xlsx")
head(Datanew)
## # A tibble: 6 × 4
##   fertilizer rainfall irrigation yield
##        <dbl>    <dbl>      <dbl> <dbl>
## 1         40      820         12    28
## 2         42      790         13    30
## 3         38      760         11    26
## 4         50      880         15    36
## 5         55      910         16    40
## 6         48      850         14    34

Structure of Dataset

str(Datanew)
## tibble [40 × 4] (S3: tbl_df/tbl/data.frame)
##  $ fertilizer: num [1:40] 40 42 38 50 55 48 60 62 45 52 ...
##  $ rainfall  : num [1:40] 820 790 760 880 910 850 940 960 810 900 ...
##  $ irrigation: num [1:40] 12 13 11 15 16 14 17 18 13 15 ...
##  $ yield     : num [1:40] 28 30 26 36 40 34 44 46 31 38 ...

Summary Statistics

summary(Datanew)
##    fertilizer       rainfall        irrigation        yield      
##  Min.   :38.00   Min.   : 760.0   Min.   :11.00   Min.   :26.00  
##  1st Qu.:45.75   1st Qu.: 827.5   1st Qu.:13.00   1st Qu.:31.75  
##  Median :53.50   Median : 897.5   Median :15.00   Median :38.50  
##  Mean   :53.35   Mean   : 889.6   Mean   :15.40   Mean   :38.40  
##  3rd Qu.:60.25   3rd Qu.: 942.5   3rd Qu.:17.25   3rd Qu.:44.25  
##  Max.   :69.00   Max.   :1010.0   Max.   :20.00   Max.   :52.00

Correlation Analysis

correlation_matrix <- cor(Datanew)

correlation_matrix
##            fertilizer  rainfall irrigation     yield
## fertilizer  1.0000000 0.9923284  0.9904526 0.9979198
## rainfall    0.9923284 1.0000000  0.9862665 0.9941276
## irrigation  0.9904526 0.9862665  1.0000000 0.9929366
## yield       0.9979198 0.9941276  0.9929366 1.0000000

Correlation Matrix Plot

corrplot(correlation_matrix,
         method = "circle",
         type = "upper",
         tl.col = "blue",
         tl.srt = 45)

Numeric Correlation Matrix

corrplot(correlation_matrix,
         method = "number",
         type = "lower")

Correlation Test

cor.test(Datanew$fertilizer,
         Datanew$yield)
## 
##  Pearson's product-moment correlation
## 
## data:  Datanew$fertilizer and Datanew$yield
## t = 95.421, df = 38, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.9960411 0.9989074
## sample estimates:
##       cor 
## 0.9979198

Scatter Plot

plot(Datanew$fertilizer,
     Datanew$yield,
     main = "Relationship Between Fertilizer and Crop Yield",
     xlab = "Fertilizer (kg/ha)",
     ylab = "Crop Yield (quintal/ha)",
     pch = 19,
     col = "blue")

Detailed Correlation Statistics

psych::corr.test(Datanew)
## Call:psych::corr.test(x = Datanew)
## Correlation matrix 
##            fertilizer rainfall irrigation yield
## fertilizer       1.00     0.99       0.99  1.00
## rainfall         0.99     1.00       0.99  0.99
## irrigation       0.99     0.99       1.00  0.99
## yield            1.00     0.99       0.99  1.00
## Sample Size 
## [1] 40
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##            fertilizer rainfall irrigation yield
## fertilizer          0        0          0     0
## rainfall            0        0          0     0
## irrigation          0        0          0     0
## yield               0        0          0     0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option