# Loading
library("readxl")
# xls files
prevalence_data <- read_excel("D:/Jeremiah/prevalence_table.xlsx")
head(prevalence_data,6)
## # A tibble: 6 x 19
## county count Day_La~1 Diurn~2 Eleva~3 Enhan~4 Land_~5 Malar~6 Malar~7 Mean_~8
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 baringo 157 26.6 11.9 1386. 0.460 21.3 0.0769 0.0516 20.9
## 2 bomet 50 33.2 12.0 793. 0.333 26.8 0.0583 0.0345 22.9
## 3 bungoma 52 29.5 13.8 1380. 0.386 25.2 0.240 0.195 23.9
## 4 busia 39 23.6 11.2 1938. 0.494 16.5 0.0717 0.0467 17.9
## 5 embu 20 23.5 13.9 2349. 0.396 16.1 0 0 17.3
## 6 garissa 11 42.5 11.5 514. 0.0940 35.0 0.0836 0.0491 29.7
## # ... with 9 more variables: Night_Land_Surface_Temp_2020 <dbl>,
## # PET_2020 <dbl>, Precipitation_2020 <dbl>, Rainfall_2020 <dbl>,
## # U5_Population_2020 <dbl>, UN_Population_Count_2020 <dbl>,
## # UN_Population_Density_2020 <dbl>, `An funestus` <dbl>, `An gambiae` <dbl>,
## # and abbreviated variable names 1: Day_Land_Surface_Temp_2020,
## # 2: Diurnal_Temperature_Range_2020, 3: Elevation,
## # 4: Enhanced_Vegetation_Index_2020, 5: Land_Surface_Temperature_2020, ...
# xlsx files
#my_data <- read_excel("my_file.xlsx")
#prevalence_data <- read.csv(file = "D:/Jeremiah/sP1 grouped.csv")
prevalence_data <- read_excel("D:/Jeremiah/prevalence_table.xlsx")
#print(prevalence_data)
# print number of columns
print (ncol(prevalence_data))
## [1] 19
# print number of rows
print(nrow(prevalence_data))
## [1] 23
# select numeric variables
df <- dplyr::select_if(prevalence_data, is.numeric)
head(df,6)
## # A tibble: 6 x 18
## count Day_La~1 Diurn~2 Eleva~3 Enhan~4 Land_~5 Malar~6 Malar~7 Mean_~8 Night~9
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 157 26.6 11.9 1386. 0.460 21.3 0.0769 0.0516 20.9 15.9
## 2 50 33.2 12.0 793. 0.333 26.8 0.0583 0.0345 22.9 20.4
## 3 52 29.5 13.8 1380. 0.386 25.2 0.240 0.195 23.9 21.0
## 4 39 23.6 11.2 1938. 0.494 16.5 0.0717 0.0467 17.9 9.27
## 5 20 23.5 13.9 2349. 0.396 16.1 0 0 17.3 8.65
## 6 11 42.5 11.5 514. 0.0940 35.0 0.0836 0.0491 29.7 27.4
## # ... with 8 more variables: PET_2020 <dbl>, Precipitation_2020 <dbl>,
## # Rainfall_2020 <dbl>, U5_Population_2020 <dbl>,
## # UN_Population_Count_2020 <dbl>, UN_Population_Density_2020 <dbl>,
## # `An funestus` <dbl>, `An gambiae` <dbl>, and abbreviated variable names
## # 1: Day_Land_Surface_Temp_2020, 2: Diurnal_Temperature_Range_2020,
## # 3: Elevation, 4: Enhanced_Vegetation_Index_2020,
## # 5: Land_Surface_Temperature_2020, 6: Malaria_Incidence_2020, ...
# calulate the correlations
r <- cor(df, use="complete.obs")
round(r,2)
## count Day_Land_Surface_Temp_2020
## count 1.00 -0.17
## Day_Land_Surface_Temp_2020 -0.17 1.00
## Diurnal_Temperature_Range_2020 0.45 -0.37
## Elevation 0.15 -0.86
## Enhanced_Vegetation_Index_2020 0.14 -0.84
## Land_Surface_Temperature_2020 -0.13 0.98
## Malaria_Incidence_2020 0.03 0.11
## Malaria_Prevalence_2020 0.06 0.06
## Mean_Temperature_2020 0.04 0.89
## Night_Land_Surface_Temp_2020 -0.09 0.92
## PET_2020 0.11 0.86
## Precipitation_2020 0.16 -0.63
## Rainfall_2020 0.08 -0.56
## U5_Population_2020 0.06 -0.03
## UN_Population_Count_2020 -0.03 0.00
## UN_Population_Density_2020 -0.03 0.00
## An funestus 0.12 -0.08
## An gambiae 0.98 -0.16
## Diurnal_Temperature_Range_2020 Elevation
## count 0.45 0.15
## Day_Land_Surface_Temp_2020 -0.37 -0.86
## Diurnal_Temperature_Range_2020 1.00 0.54
## Elevation 0.54 1.00
## Enhanced_Vegetation_Index_2020 0.25 0.50
## Land_Surface_Temperature_2020 -0.33 -0.91
## Malaria_Incidence_2020 0.19 -0.28
## Malaria_Prevalence_2020 0.22 -0.22
## Mean_Temperature_2020 -0.31 -0.91
## Night_Land_Surface_Temp_2020 -0.29 -0.93
## PET_2020 -0.04 -0.71
## Precipitation_2020 0.42 0.41
## Rainfall_2020 0.31 0.33
## U5_Population_2020 -0.04 0.16
## UN_Population_Count_2020 -0.11 0.12
## UN_Population_Density_2020 -0.11 0.12
## An funestus 0.14 -0.04
## An gambiae 0.42 0.16
## Enhanced_Vegetation_Index_2020
## count 0.14
## Day_Land_Surface_Temp_2020 -0.84
## Diurnal_Temperature_Range_2020 0.25
## Elevation 0.50
## Enhanced_Vegetation_Index_2020 1.00
## Land_Surface_Temperature_2020 -0.74
## Malaria_Incidence_2020 0.27
## Malaria_Prevalence_2020 0.28
## Mean_Temperature_2020 -0.59
## Night_Land_Surface_Temp_2020 -0.61
## PET_2020 -0.67
## Precipitation_2020 0.77
## Rainfall_2020 0.76
## U5_Population_2020 -0.21
## UN_Population_Count_2020 -0.23
## UN_Population_Density_2020 -0.23
## An funestus 0.24
## An gambiae 0.09
## Land_Surface_Temperature_2020
## count -0.13
## Day_Land_Surface_Temp_2020 0.98
## Diurnal_Temperature_Range_2020 -0.33
## Elevation -0.91
## Enhanced_Vegetation_Index_2020 -0.74
## Land_Surface_Temperature_2020 1.00
## Malaria_Incidence_2020 0.24
## Malaria_Prevalence_2020 0.18
## Mean_Temperature_2020 0.95
## Night_Land_Surface_Temp_2020 0.98
## PET_2020 0.89
## Precipitation_2020 -0.52
## Rainfall_2020 -0.46
## U5_Population_2020 -0.08
## UN_Population_Count_2020 -0.05
## UN_Population_Density_2020 -0.05
## An funestus 0.01
## An gambiae -0.13
## Malaria_Incidence_2020 Malaria_Prevalence_2020
## count 0.03 0.06
## Day_Land_Surface_Temp_2020 0.11 0.06
## Diurnal_Temperature_Range_2020 0.19 0.22
## Elevation -0.28 -0.22
## Enhanced_Vegetation_Index_2020 0.27 0.28
## Land_Surface_Temperature_2020 0.24 0.18
## Malaria_Incidence_2020 1.00 0.99
## Malaria_Prevalence_2020 0.99 1.00
## Mean_Temperature_2020 0.33 0.27
## Night_Land_Surface_Temp_2020 0.35 0.29
## PET_2020 0.23 0.18
## Precipitation_2020 0.51 0.52
## Rainfall_2020 0.62 0.64
## U5_Population_2020 -0.13 -0.09
## UN_Population_Count_2020 -0.13 -0.09
## UN_Population_Density_2020 -0.13 -0.09
## An funestus 0.17 0.12
## An gambiae 0.00 0.04
## Mean_Temperature_2020
## count 0.04
## Day_Land_Surface_Temp_2020 0.89
## Diurnal_Temperature_Range_2020 -0.31
## Elevation -0.91
## Enhanced_Vegetation_Index_2020 -0.59
## Land_Surface_Temperature_2020 0.95
## Malaria_Incidence_2020 0.33
## Malaria_Prevalence_2020 0.27
## Mean_Temperature_2020 1.00
## Night_Land_Surface_Temp_2020 0.96
## PET_2020 0.92
## Precipitation_2020 -0.44
## Rainfall_2020 -0.36
## U5_Population_2020 -0.18
## UN_Population_Count_2020 -0.16
## UN_Population_Density_2020 -0.16
## An funestus 0.08
## An gambiae 0.02
## Night_Land_Surface_Temp_2020 PET_2020
## count -0.09 0.11
## Day_Land_Surface_Temp_2020 0.92 0.86
## Diurnal_Temperature_Range_2020 -0.29 -0.04
## Elevation -0.93 -0.71
## Enhanced_Vegetation_Index_2020 -0.61 -0.67
## Land_Surface_Temperature_2020 0.98 0.89
## Malaria_Incidence_2020 0.35 0.23
## Malaria_Prevalence_2020 0.29 0.18
## Mean_Temperature_2020 0.96 0.92
## Night_Land_Surface_Temp_2020 1.00 0.88
## PET_2020 0.88 1.00
## Precipitation_2020 -0.40 -0.50
## Rainfall_2020 -0.34 -0.43
## U5_Population_2020 -0.13 -0.16
## UN_Population_Count_2020 -0.10 -0.16
## UN_Population_Density_2020 -0.10 -0.16
## An funestus 0.09 0.08
## An gambiae -0.11 0.09
## Precipitation_2020 Rainfall_2020
## count 0.16 0.08
## Day_Land_Surface_Temp_2020 -0.63 -0.56
## Diurnal_Temperature_Range_2020 0.42 0.31
## Elevation 0.41 0.33
## Enhanced_Vegetation_Index_2020 0.77 0.76
## Land_Surface_Temperature_2020 -0.52 -0.46
## Malaria_Incidence_2020 0.51 0.62
## Malaria_Prevalence_2020 0.52 0.64
## Mean_Temperature_2020 -0.44 -0.36
## Night_Land_Surface_Temp_2020 -0.40 -0.34
## PET_2020 -0.50 -0.43
## Precipitation_2020 1.00 0.93
## Rainfall_2020 0.93 1.00
## U5_Population_2020 -0.03 -0.01
## UN_Population_Count_2020 -0.05 -0.03
## UN_Population_Density_2020 -0.05 -0.03
## An funestus 0.45 0.40
## An gambiae 0.07 -0.01
## U5_Population_2020 UN_Population_Count_2020
## count 0.06 -0.03
## Day_Land_Surface_Temp_2020 -0.03 0.00
## Diurnal_Temperature_Range_2020 -0.04 -0.11
## Elevation 0.16 0.12
## Enhanced_Vegetation_Index_2020 -0.21 -0.23
## Land_Surface_Temperature_2020 -0.08 -0.05
## Malaria_Incidence_2020 -0.13 -0.13
## Malaria_Prevalence_2020 -0.09 -0.09
## Mean_Temperature_2020 -0.18 -0.16
## Night_Land_Surface_Temp_2020 -0.13 -0.10
## PET_2020 -0.16 -0.16
## Precipitation_2020 -0.03 -0.05
## Rainfall_2020 -0.01 -0.03
## U5_Population_2020 1.00 0.99
## UN_Population_Count_2020 0.99 1.00
## UN_Population_Density_2020 0.99 1.00
## An funestus -0.14 -0.15
## An gambiae 0.09 0.00
## UN_Population_Density_2020 An funestus
## count -0.03 0.12
## Day_Land_Surface_Temp_2020 0.00 -0.08
## Diurnal_Temperature_Range_2020 -0.11 0.14
## Elevation 0.12 -0.04
## Enhanced_Vegetation_Index_2020 -0.23 0.24
## Land_Surface_Temperature_2020 -0.05 0.01
## Malaria_Incidence_2020 -0.13 0.17
## Malaria_Prevalence_2020 -0.09 0.12
## Mean_Temperature_2020 -0.16 0.08
## Night_Land_Surface_Temp_2020 -0.10 0.09
## PET_2020 -0.16 0.08
## Precipitation_2020 -0.05 0.45
## Rainfall_2020 -0.03 0.40
## U5_Population_2020 0.99 -0.14
## UN_Population_Count_2020 1.00 -0.15
## UN_Population_Density_2020 1.00 -0.15
## An funestus -0.15 1.00
## An gambiae 0.00 -0.09
## An gambiae
## count 0.98
## Day_Land_Surface_Temp_2020 -0.16
## Diurnal_Temperature_Range_2020 0.42
## Elevation 0.16
## Enhanced_Vegetation_Index_2020 0.09
## Land_Surface_Temperature_2020 -0.13
## Malaria_Incidence_2020 0.00
## Malaria_Prevalence_2020 0.04
## Mean_Temperature_2020 0.02
## Night_Land_Surface_Temp_2020 -0.11
## PET_2020 0.09
## Precipitation_2020 0.07
## Rainfall_2020 -0.01
## U5_Population_2020 0.09
## UN_Population_Count_2020 0.00
## UN_Population_Density_2020 0.00
## An funestus -0.09
## An gambiae 1.00
library(ggplot2)
library(ggcorrplot)
ggcorrplot(r)

ggcorrplot(r,
hc.order = TRUE,
type = "lower",
lab = TRUE)

library(ggplot2)
library(ggcorrplot)
library(corrplot)
## corrplot 0.92 loaded
library(RColorBrewer)
corrplot(r, type="upper", order="hclust",
col=brewer.pal(n=8, name="RdYlBu"))
