R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

plot(pressure)

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Spacial Visualization

library(sf)
## Linking to GEOS 3.11.2, GDAL 3.6.2, PROJ 9.2.0; sf_use_s2() is TRUE
library(tmap)
## The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
## which was just loaded, will retire in October 2023.
## Please refer to R-spatial evolution reports for details, especially
## https://r-spatial.org/r/2023/05/15/evolution4.html.
## It may be desirable to make the sf package available;
## package maintainers should consider adding sf to Suggests:.
## The sp package is now running under evolution status 2
##      (status 2 uses the sf package in place of rgdal)
## Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
## remotes::install_github('r-tmap/tmap')
library(rgdal)
## Loading required package: sp
## Please note that rgdal will be retired during October 2023,
## plan transition to sf/stars/terra functions using GDAL and PROJ
## at your earliest convenience.
## See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
## rgdal: version: 1.6-7, (SVN revision 1203)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
## Path to GDAL shared files: C:/Users/LENOVO/AppData/Local/R/win-library/4.3/rgdal/gdal
##  GDAL does not use iconv for recoding strings.
## GDAL binary built with GEOS: TRUE 
## Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
## Path to PROJ shared files: C:/Users/LENOVO/AppData/Local/R/win-library/4.3/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:2.0-0
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
library(readxl)
library(dplyr)
## 
## 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
rm(list=ls())
ind=readOGR(dsn="F:/Collage/Semester 5/Bintel/Week 6/PROVINSI_JAWA_TIMUR/PROVINSI_JAWA_TIMUR/PROVINSI_JAWA_TIMUR.shp")
## Warning: OGR support is provided by the sf and terra packages among others
## Warning: OGR support is provided by the sf and terra packages among others
## Warning: OGR support is provided by the sf and terra packages among others
## Warning: OGR support is provided by the sf and terra packages among others
## Warning: OGR support is provided by the sf and terra packages among others
## Warning: OGR support is provided by the sf and terra packages among others
## Warning: OGR support is provided by the sf and terra packages among others
## OGR data source with driver: ESRI Shapefile 
## Source: "F:\Collage\Semester 5\Bintel\Week 6\PROVINSI_JAWA_TIMUR\PROVINSI_JAWA_TIMUR\PROVINSI_JAWA_TIMUR.shp", layer: "PROVINSI_JAWA_TIMUR"
## with 38 features
## It has 4 fields
## Warning in readOGR(dsn = "F:/Collage/Semester 5/Bintel/Week
## 6/PROVINSI_JAWA_TIMUR/PROVINSI_JAWA_TIMUR/PROVINSI_JAWA_TIMUR.shp"):
## Z-dimension discarded
head(ind@data, n=38)
plot(ind)

data1<- read_excel("F:/Collage/Semester 5/Bintel/Week 6/data_PDRB.xlsx", sheet = "signif")
data1=data.frame(data1)
summary(data1)
##    Kab_Kota          Kabupaten               b0                 b1       
##  Length:38          Length:38          Min.   :-12.7732   Min.   :1.031  
##  Class :character   Class :character   1st Qu.: -7.0911   1st Qu.:1.069  
##  Mode  :character   Mode  :character   Median : -4.4752   Median :1.085  
##                                        Mean   : -4.8739   Mean   :1.084  
##                                        3rd Qu.: -1.7309   3rd Qu.:1.101  
##                                        Max.   :  0.6925   Max.   :1.123  
##        b2                b3                 b4               b5         
##  Min.   :-0.4524   Min.   :-0.23040   Min.   :0.5039   Min.   :-1.7255  
##  1st Qu.:-0.3226   1st Qu.: 0.06598   1st Qu.:0.8385   1st Qu.:-1.4820  
##  Median :-0.2830   Median : 0.24385   Median :0.8899   Median :-1.3032  
##  Mean   :-0.2641   Mean   : 0.19618   Mean   :0.9930   Mean   :-1.2150  
##  3rd Qu.:-0.2160   3rd Qu.: 0.31160   3rd Qu.:1.0684   3rd Qu.:-0.9526  
##  Max.   : 0.0464   Max.   : 0.53420   Max.   :1.8022   Max.   : 0.0293  
##       tb0               tb1              tb2               tb3         
##  Min.   :-2.1520   Min.   : 3.233   Min.   :-2.3448   Min.   :-0.3701  
##  1st Qu.:-1.6298   1st Qu.:11.282   1st Qu.:-2.0538   1st Qu.: 0.2462  
##  Median :-1.2409   Median :12.186   Median :-1.8062   Median : 0.9794  
##  Mean   :-1.1672   Mean   :11.687   Mean   :-1.5927   Mean   : 0.7543  
##  3rd Qu.:-0.4075   3rd Qu.:13.038   3rd Qu.:-1.3380   3rd Qu.: 1.1787  
##  Max.   : 0.0626   Max.   :13.718   Max.   : 0.1562   Max.   : 1.3157  
##       tb4              tb5                R2         Variabel_Signifikan
##  Min.   :0.4071   Min.   :-1.5780   Min.   :0.8927   Length:38          
##  1st Qu.:1.7558   1st Qu.:-1.2116   1st Qu.:0.9622   Class :character   
##  Median :2.1040   Median :-0.9830   Median :0.9667   Mode  :character   
##  Mean   :2.0318   Mean   :-0.9734   Mean   :0.9633                      
##  3rd Qu.:2.3235   3rd Qu.:-0.7485   3rd Qu.:0.9697                      
##  Max.   :2.7422   Max.   : 0.0222   Max.   :0.9734                      
##   Intercept             PAD            Kematian_COVID     Pengeluaran_perkapita
##  Length:38          Length:38          Length:38          Length:38            
##  Class :character   Class :character   Class :character   Class :character     
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character     
##                                                                                
##                                                                                
##                                                                                
##      DAU                DAK                  u               v        
##  Length:38          Length:38          Min.   :6.520   Min.   :111.1  
##  Class :character   Class :character   1st Qu.:7.247   1st Qu.:111.7  
##  Mode  :character   Mode  :character   Median :7.410   Median :112.3  
##                                        Mean   :7.463   Mean   :112.3  
##                                        3rd Qu.:7.577   3rd Qu.:112.9  
##                                        Max.   :8.160   Max.   :114.2  
##     KABKOT         
##  Length:38         
##  Class :character  
##  Mode  :character  
##                    
##                    
## 

Menggabungkan Data

head(data1)
ind@data<-left_join(ind@data,data1,by="KABKOT")

Visualisasi Map

tmap_options(check.and.fix = TRUE)
qtm(ind,fill="Variabel_Signifikan",text="Kabupaten",text.size=0.5)
## Warning: The shape ind is invalid. See sf::st_is_valid

qtm(ind,fill="PAD",text="Kabupaten",fill.palette=c("#B0C4B1"),text.size=0.5)
## Warning: The shape ind is invalid. See sf::st_is_valid

qtm(ind,fill="Kematian_COVID",text="Kabupaten",fill.palette=c("#EDAFB8","white"),text.size=0.5)
## Warning: The shape ind is invalid. See sf::st_is_valid

qtm(ind,fill="Pengeluaran_perkapita",fill.palette=c("white"),text="Kabupaten",text.size=0.5)
## Warning: The shape ind is invalid. See sf::st_is_valid

qtm(ind,fill="DAU",text="Kabupaten",fill.palette=c("#B0C4B1","white"),text.size=0.5)
## Warning: The shape ind is invalid. See sf::st_is_valid

qtm(ind,fill="DAK",text="Kabupaten",fill.palette=c("white"),text.size=0.5)
## Warning: The shape ind is invalid. See sf::st_is_valid