|
4 | 4 | #' masses relevant to the taxon of interest. |
5 | 5 | #' @param occs The dataframe that is returned by `SSARP::find_land()`. If using |
6 | 6 | #' a custom occurrence record dataframe, ensure that it has the following |
7 | | -#' columns in order: "SpeciesName", "Genus", "Species", "Longitude", "Latitude", |
8 | | -#' "First", "Second", "Third", "datasetKey". The "datasetKey" column is |
9 | | -#' important for GBIF records and identifies the dataset to which the occurrence |
10 | | -#' record belongs. Custom dataframes without this style of data organization |
11 | | -#' should fill the column with placeholder values. |
| 7 | +#' columns: "acceptedScientificName", "genericName", "specificEpithet", |
| 8 | +#' "decimalLongitude", "decimalLatitude", "First", "Second", "Third", |
| 9 | +#' "datasetKey". The "datasetKey" column is important for GBIF records and |
| 10 | +#' identifies the dataset to which the occurrence record belongs. Custom |
| 11 | +#' dataframes without this style of data organization should fill the column |
| 12 | +#' with placeholder values. |
12 | 13 | #' @param area_custom A dataframe including names of land masses and their |
13 | 14 | #' associated areas. This dataframe should be provided when the user would like |
14 | 15 | #' to bypass using the built-in database of island names and areas. Please |
@@ -41,7 +42,7 @@ find_areas <- function(occs, area_custom = NULL) { |
41 | 42 | cli::cli_alert_warning("No data in occurrence record dataframe") |
42 | 43 | break |
43 | 44 | } |
44 | | - if(is.na(occs[i,8]) && is.na(occs[i,7]) && is.na(occs[i,6])) { |
| 45 | + if(is.na(occs[i,"Third"]) && is.na(occs[i,"Second"]) && is.na(occs[i,"First"])) { |
45 | 46 | minus[i] <- i |
46 | 47 | } |
47 | 48 | } |
@@ -74,12 +75,12 @@ find_areas <- function(occs, area_custom = NULL) { |
74 | 75 | cli::cli_alert_warning("No data in occurrence record dataframe") |
75 | 76 | break |
76 | 77 | } |
77 | | - if(!is.na(occs[i,8])) { |
78 | | - islands[i] <- occs[i,8] |
79 | | - } else if (!is.na(occs[i,7])){ |
80 | | - islands[i] <- occs[i,7] |
81 | | - } else if (!is.na(occs[i,6])){ |
82 | | - islands[i] <- occs[i,6] |
| 78 | + if(!is.na(occs[i,"Third"])) { |
| 79 | + islands[i] <- occs[i,"Third"] |
| 80 | + } else if (!is.na(occs[i,"Second"])){ |
| 81 | + islands[i] <- occs[i,"Second"] |
| 82 | + } else if (!is.na(occs[i,"First"])){ |
| 83 | + islands[i] <- occs[i,"First"] |
83 | 84 | } |
84 | 85 | } |
85 | 86 |
|
@@ -141,12 +142,12 @@ find_areas <- function(occs, area_custom = NULL) { |
141 | 142 |
|
142 | 143 | for(i in seq_len(nrow(occs))) { |
143 | 144 |
|
144 | | - if(!is.na(occs[i,8]) && island_dict$has(occs[i,8])){ |
145 | | - areas[i] <- island_dict$get(occs[i,8]) |
146 | | - } else if(!is.na(occs[i,7]) && island_dict$has(occs[i,7])){ |
147 | | - areas[i] <- island_dict$get(occs[i,7]) |
148 | | - } else if(!is.na(occs[i,6]) && island_dict$has(occs[i,6])){ |
149 | | - areas[i] <- island_dict$get(occs[i,6]) |
| 145 | + if(!is.na(occs[i,"Third"]) && island_dict$has(occs[i,"Third"])){ |
| 146 | + areas[i] <- island_dict$get(occs[i,"Third"]) |
| 147 | + } else if(!is.na(occs[i,"Second"]) && island_dict$has(occs[i,"Second"])){ |
| 148 | + areas[i] <- island_dict$get(occs[i,"Second"]) |
| 149 | + } else if(!is.na(occs[i,"First"]) && island_dict$has(occs[i,"First"])){ |
| 150 | + areas[i] <- island_dict$get(occs[i,"First"]) |
150 | 151 | } else { |
151 | 152 | areas[i] <- NA |
152 | 153 | } |
|
0 commit comments