You can rewrite this as below. This makes the program flow easier to understand since the shortest branch is handled first and it end the function. Hence you don't need to write the second part as an else statement.
if (nrow(df_cleaned_data) == 0)) {
warning("All observations are judged imprecise or suspected.")
return(NULL)
}
df_with_cellcode <- assign_eea_cell(df = df_cleaned_data,
longitude_colname = longitude_colname,
latitude_colname = latitude_colname)
df_n_obs_cell <- get_n_obs_per_cell(df = df_with_cellcode)
df_cells_with_obs <- cells_with_obs(grid_cells = grid_cells,
n_obs_per_cell = df_n_obs_cell)
visualize_obs_cells(sf_df = df_cells_with_obs,
species = species,
year = year,
palette = palette,
fill_color_opacity = fill_color_opacity)
|
if (nrow(df_cleaned_data > 0)) { |
In this case I'd rather throw an error than a warning.
assert_that(nrow(df_cleaned_data) > 0, msg = "All observations are judged imprecise or suspected.")
You can rewrite this as below. This makes the program flow easier to understand since the shortest branch is handled first and it end the function. Hence you don't need to write the second part as an
elsestatement.coding-club/src/20210624/20210624_functions_solutions.R
Line 219 in 2a0865f
In this case I'd rather throw an error than a warning.