This function calculates the mean density of hexagonal bins based on their neighboring bins.
Usage
compute_mean_density_hex(
df_bin_centroids,
num_bins_x,
col_std_counts = "std_counts",
col_hb_id = "hexID"
)
Arguments
- df_bin_centroids
A data frame containing information about hexagonal bin centroids, including the hexagon ID and the standard normalized counts (
std_counts
).- num_bins_x
The number of bins along the x-axis for the hexagonal grid.
- col_std_counts
The name of the column containing the standardized counts.
- col_hb_id
The name of the column containing the hexagonal bin IDs.
Value
A data frame with an additional column, mean_density
, representing the mean
density of each hexagonal bin based on its neighboring bins.
Examples
num_bins_x <- 4
shape_value <- 1.833091
hexbin_data_object <- extract_hexbin_centroids(nldr_df = s_curve_noise_umap,
num_bins = num_bins_x, shape_val = shape_value)
df_bin_centroids <- hexbin_data_object$hexdf_data
compute_mean_density_hex(df_bin_centroids, num_bins_x)
#> # A tibble: 16 × 6
#> x y hexID counts std_counts mean_density
#> <dbl> <dbl> <int> <int> <dbl> <dbl>
#> 1 -3.27 -5.74 1 2 0.222 0.722
#> 2 -1.84 -5.74 2 6 0.667 0.519
#> 3 -2.55 -4.38 6 7 0.778 0.417
#> 4 -1.12 -4.38 7 5 0.556 0.472
#> 5 -3.27 -3.01 11 2 0.222 0.519
#> 6 -1.84 -3.01 12 2 0.222 0.278
#> 7 -0.407 -3.01 13 2 0.222 0.407
#> 8 -1.12 -1.65 17 1 0.111 0.444
#> 9 0.308 -1.65 18 8 0.889 0.167
#> 10 1.02 -0.280 24 7 0.778 0.389
#> 11 0.308 1.09 28 1 0.111 0.722
#> 12 1.74 1.09 29 6 0.667 0.444
#> 13 0.308 3.82 38 2 0.222 0.889
#> 14 1.74 3.82 39 8 0.889 0.611
#> 15 1.02 5.18 44 9 1 0.833
#> 16 2.46 5.18 45 7 0.778 1