Skip to contents

glapply is an implementation of lapply especially for geolists. FUN is applied to each element of the geolist and a geolist of the same length is returned.

Usage

glapply(X, FUN, ...)

Arguments

X

a vector (atomic or list) or an expression object. Other objects (including classed objects) will be coerced by base::as.list.

FUN

the function to be applied to each element of X: see ‘Details’. In the case of functions like +, %*%, the function name must be backquoted or quoted.

...

optional arguments to FUN.

Value

A geolist of the same length as X with FUN applied to all elements.

Examples

glapply(det_grid_df$fcst, sqrt)
#> <harp_geolist[24]>
#>  [[1]] <numeric geofield [5 x 5] Min = 0.132 Max = 0.988 Mean = 0.634>
#>  [[2]] <numeric geofield [5 x 5] Min = 0.146 Max = 0.980 Mean = 0.599>
#>  [[3]] <numeric geofield [5 x 5] Min = 0.246 Max = 0.932 Mean = 0.619>
#>  [[4]] <numeric geofield [5 x 5] Min = 0.173 Max = 0.993 Mean = 0.699>
#>  [[5]] <numeric geofield [5 x 5] Min = 0.025 Max = 0.993 Mean = 0.669>
#>  [[6]] <numeric geofield [5 x 5] Min = 0.037 Max = 0.944 Mean = 0.662>
#>  [[7]] <numeric geofield [5 x 5] Min = 0.058 Max = 0.992 Mean = 0.636>
#>  [[8]] <numeric geofield [5 x 5] Min = 0.321 Max = 0.987 Mean = 0.704>
#>  [[9]] <numeric geofield [5 x 5] Min = 0.039 Max = 0.984 Mean = 0.627>
#> [[10]] <numeric geofield [5 x 5] Min = 0.195 Max = 0.965 Mean = 0.657>
#> # 14 more geofields
#> # Use `print(n = ...)` to see more
#> 

glapply(det_grid_df$fcst, function(x) x + 10)
#> <harp_geolist[24]>
#>  [[1]] <numeric geofield [5 x 5] Min = 10.018 Max = 10.976 Mean = 10.460>
#>  [[2]] <numeric geofield [5 x 5] Min = 10.021 Max = 10.960 Mean = 10.418>
#>  [[3]] <numeric geofield [5 x 5] Min = 10.060 Max = 10.868 Mean = 10.422>
#>  [[4]] <numeric geofield [5 x 5] Min = 10.030 Max = 10.986 Mean = 10.538>
#>  [[5]] <numeric geofield [5 x 5] Min = 10.001 Max = 10.985 Mean = 10.514>
#>  [[6]] <numeric geofield [5 x 5] Min = 10.001 Max = 10.891 Mean = 10.492>
#>  [[7]] <numeric geofield [5 x 5] Min = 10.003 Max = 10.984 Mean = 10.472>
#>  [[8]] <numeric geofield [5 x 5] Min = 10.103 Max = 10.974 Mean = 10.531>
#>  [[9]] <numeric geofield [5 x 5] Min = 10.002 Max = 10.969 Mean = 10.467>
#> [[10]] <numeric geofield [5 x 5] Min = 10.038 Max = 10.930 Mean = 10.492>
#> # 14 more geofields
#> # Use `print(n = ...)` to see more
#>