1 objetivo

4 transform data

## [1] "tbl_df"     "tbl"        "data.frame"
## # A tibble: 2,036 x 3
##          x       y marks            
##      <dbl>   <dbl> <fct>            
##  1 354558. 429074. Non-violent crime
##  2 353666. 429243. Non-violent crime
##  3 355801. 430015. Non-violent crime
##  4 352859. 429319. Non-violent crime
##  5 353560. 430174. Non-violent crime
##  6 351079. 431580. Non-violent crime
##  7 351046. 431497. Non-violent crime
##  8 354018. 429239. Non-violent crime
##  9 350119. 430782. Non-violent crime
## 10 355248. 431478. Non-violent crime
## # ... with 2,026 more rows
## [1] "sf"         "tbl_df"     "tbl"        "data.frame"
## Simple feature collection with 2036 features and 3 fields
## Attribute-geometry relationship: 3 constant, 0 aggregate, 0 identity
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: 350000 ymin: 430000 xmax: 360000 ymax: 430000
## epsg (SRID):    27561
## proj4string:    +proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs
## # A tibble: 2,036 x 4
##          x       y marks                    geometry
##      <dbl>   <dbl> <fct>                 <POINT [m]>
##  1 354558. 429074. Non-violent crime (354558 429074)
##  2 353666. 429243. Non-violent crime (353666 429243)
##  3 355801. 430015. Non-violent crime (355801 430015)
##  4 352859. 429319. Non-violent crime (352859 429319)
##  5 353560. 430174. Non-violent crime (353560 430174)
##  6 351079. 431580. Non-violent crime (351079 431580)
##  7 351046. 431497. Non-violent crime (351046 431497)
##  8 354018. 429239. Non-violent crime (354018 429239)
##  9 350119. 430782. Non-violent crime (350119 430782)
## 10 355248. 431478. Non-violent crime (355248 431478)
## # ... with 2,026 more rows

6 kernel smoothing

6.1 binwidth selection

6.1.1 histogram

binwidth =

The width of the bins. Can be specified as a numeric value or as a function that calculates width from unscaled x. Here, “unscaled x” refers to the original x values in the data, before application of any scale transformation. When specifying a function along with a grouping structure, the function will be called once per group. The default is to use the number of bins in bins, covering the range of the data. You should always override this value, exploring multiple widths to find the best to illustrate the stories in your data.

6.1.2 density

stat_density

Computes and draws kernel density estimate, which is a smoothed version of the histogram. This is a useful alternative to the histogram for continuous data that comes from an underlying smooth distribution.

bw =

The smoothing bandwidth to be used. If numeric, the standard deviation of the smoothing kernel. If character, a rule to choose the bandwidth, as listed in stats::bw.nrd().

6.2 density 2d

stat_density_2d

Perform a 2D kernel density estimation using MASS::kde2d() and display the results with contours. This can be useful for dealing with overplotting. This is a 2d version of geom_density().

h =

Bandwidth (vector of length two). If NULL, estimated using MASS::bandwidth.nrd()

6.2.1 how to choose the better bandwidth?

bw.scott

Use Scott’s rule of thumb to determine the smoothing bandwidth for the kernel estimation of point process intensity.

This function selects a bandwidth sigma for the kernel estimator of point process intensity computed by density.ppp.

## sigma.x sigma.y 
##     472     422