From a4dff9e442b17a6b0acb89f1437827056382541b Mon Sep 17 00:00:00 2001 From: Jonathan Callahan Date: Thu, 14 Jul 2022 11:55:46 -0700 Subject: [PATCH] fix: table_updateColumn() now ignores unknown locationIDs --- DESCRIPTION | 2 +- NEWS.md | 5 + R/table_updateColumn.R | 29 ++- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/articles/MazamaLocationUtils.html | 125 +++++++++--- .../header-attrs-2.14/header-attrs.js | 12 ++ docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 99 +++++++--- docs/news/index.html | 185 +++++++++++++----- docs/pkgdown.yml | 4 +- docs/reference/LocationDataDir.html | 2 +- docs/reference/MazamaLocationUtils.html | 2 +- docs/reference/coreMetadataNames.html | 2 +- docs/reference/getAPIKey.html | 2 +- docs/reference/getLocationDataDir.html | 2 +- docs/reference/id_monitors_500.html | 2 +- docs/reference/index.html | 2 +- docs/reference/location_createID.html | 2 +- docs/reference/location_getCensusBlock.html | 2 +- docs/reference/location_getOpenCageInfo.html | 2 +- .../location_getSingleAddress_Photon.html | 2 +- .../location_getSingleAddress_TexasAM.html | 2 +- .../location_getSingleElevation_USGS.html | 2 +- docs/reference/location_initialize.html | 2 +- docs/reference/mazama_initialize.html | 2 +- docs/reference/or_monitors_500.html | 2 +- docs/reference/pipe.html | 2 +- docs/reference/setAPIKey.html | 2 +- docs/reference/setLocationDataDir.html | 2 +- docs/reference/showAPIKeys.html | 2 +- docs/reference/table_addColumn.html | 2 +- docs/reference/table_addCoreMetadata.html | 2 +- docs/reference/table_addLocation.html | 2 +- docs/reference/table_addOpenCageInfo.html | 2 +- docs/reference/table_addSingleLocation.html | 2 +- docs/reference/table_filterByDistance.html | 2 +- .../table_findAdjacentDistances.html | 2 +- .../table_findAdjacentLocations.html | 2 +- .../table_getDistanceFromTarget.html | 2 +- docs/reference/table_getLocationID.html | 2 +- docs/reference/table_getNearestDistance.html | 2 +- docs/reference/table_getNearestLocation.html | 2 +- docs/reference/table_getRecordIndex.html | 2 +- docs/reference/table_initialize.html | 2 +- docs/reference/table_initializeExisting.html | 2 +- docs/reference/table_leaflet.html | 2 +- docs/reference/table_leafletAdd.html | 2 +- docs/reference/table_load.html | 2 +- docs/reference/table_removeColumn.html | 2 +- docs/reference/table_removeRecord.html | 2 +- docs/reference/table_save.html | 4 +- docs/reference/table_updateColumn.html | 28 ++- docs/reference/table_updateSingleRecord.html | 2 +- docs/reference/validateLocationTbl.html | 2 +- docs/reference/validateLonLat.html | 2 +- docs/reference/validateLonsLats.html | 2 +- .../reference/validateMazamaSpatialUtils.html | 2 +- docs/reference/wa_airfire_meta.html | 2 +- docs/reference/wa_monitors_500.html | 2 +- man/table_updateColumn.Rd | 17 +- tests/testthat/test-table_updateColumn.R | 26 +++ 63 files changed, 458 insertions(+), 180 deletions(-) create mode 100644 docs/articles/MazamaLocationUtils_files/header-attrs-2.14/header-attrs.js diff --git a/DESCRIPTION b/DESCRIPTION index ad4f86f..664c77d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Type: Package Package: MazamaLocationUtils -Version: 0.3.6 +Version: 0.3.7 Title: Manage Spatial Metadata for Known Locations Authors@R: c( person("Jonathan", "Callahan", email="jonathan.s.callahan@gmail.com", role=c("aut","cre")), diff --git a/NEWS.md b/NEWS.md index 35cb155..5f630eb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# MazamaLocationUtils 0.3.7 + +* Updated `table_updateColumn()` to ignore incoming `locationIDs` that are not +found in the `locationTbl`. + # MazamaLocationUtils 0.3.6 * Added `table_getDistanceFromTarget()` and edited the description of other diff --git a/R/table_updateColumn.R b/R/table_updateColumn.R index 65deed6..32fc2c8 100644 --- a/R/table_updateColumn.R +++ b/R/table_updateColumn.R @@ -1,12 +1,21 @@ #' @title Update a column of metadata in a table -#' @description For matching \code{locationID}, records the associated -#' \code{locationData} is used to replace any existing value in \code{columnName}. -#' \code{NA} values in \code{locationID} will be ignored. +#' +#' @description Updates records in a location table. Records are identified +#' by \code{locationID} and the data found in \code{locationData} is used to +#' replace any existing value in the \code{columnName} column. +#' \code{locationID} and \code{locationData} must be of the same length. +#' Any \code{NA} values in \code{locationID} will be ignored. +#' +#' If \code{columnName} is not a named column within \code{locationTbl}, a new +#' column will be created. +#' #' @param locationTbl Tibble of known locations. -#' @param columnName Name to use for the new column. +#' @param columnName Name of an existing/new column in \code{locationTbl} whose data +#' will be updated/created. #' @param locationID Vector of \code{locationID} strings. -#' @param locationData Vector of data to used at matching records. +#' @param locationData Vector of data to be inserted at records identified by +#' \code{locationID}. #' @param verbose Logical controlling the generation of progress messages. #' @return Updated tibble of known locations. #' @examples @@ -47,6 +56,7 @@ #' @export #' @importFrom MazamaCoreUtils stopIfNull #' @importFrom dplyr bind_rows + table_updateColumn <- function( locationTbl = NULL, columnName = NULL, @@ -86,8 +96,15 @@ table_updateColumn <- function( locationTbl <- table_addColumn(locationTbl, columnName) if ( !is.null(locationData) ) { - # Get the indices to be updated + # Get the record indices to be updated recordIndex <- table_getRecordIndex(locationTbl, locationID) + + # Remove incoming locationData not associated with any record + mask <- !is.na(recordIndex) + recordIndex <- recordIndex[mask] + locationData <- locationData[mask] + + # Updated record data locationTbl[[columnName]][recordIndex] <- locationData } diff --git a/docs/404.html b/docs/404.html index 26c5010..d3600ec 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 2a96cf1..b3a15d1 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -71,7 +71,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/articles/MazamaLocationUtils.html b/docs/articles/MazamaLocationUtils.html index 7d5d137..c37ac80 100644 --- a/docs/articles/MazamaLocationUtils.html +++ b/docs/articles/MazamaLocationUtils.html @@ -31,7 +31,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 @@ -70,7 +70,7 @@ -
+
+
+

+MazamaLocationUtils 0.3.7 Unreleased +

+
    +
  • Updated table_updateColumn() to ignore incoming +locationIDs that are not found in the +locationTbl.
  • +
+

MazamaLocationUtils 0.3.6 Unreleased

@@ -130,7 +142,9 @@

MazamaLocationUtils 0.3.5 Unreleased

@@ -138,7 +152,8 @@

MazamaLocationUtils 0.3.4 Unreleased

@@ -146,8 +161,11 @@

MazamaLocationUtils 0.3.3 2022-02-11

@@ -156,8 +174,10 @@

MazamaLocationUtils 0.3.2 Unreleased

    -
  • Ensure that address components are of class “character” throughout the code.
  • -
  • Added location_getOpenCageInfo() to get OpenCage information for a single location.
  • +
  • Ensure that address components are of class “character” throughout +the code.
  • +
  • Added location_getOpenCageInfo() to get OpenCage +information for a single location.
@@ -165,7 +185,8 @@

MazamaLocationUtils 0.3.1 2022-01-16

@@ -174,9 +195,11 @@

MazamaLocationUtils 0.3.0 Unreleased

@@ -184,9 +207,12 @@

MazamaLocationUtils 0.2.9 Unreleased

@@ -202,9 +228,12 @@

MazamaLocationUtils 0.2.7 2021-11-16

    -
  • All examples now meet the CRAN directive to avoid stopping if a web resource is unavailable.
  • -
  • Improved error messages in table_load() and table_save().
  • -
  • Removed table_export(). Use table_save() instead.
  • +
  • All examples now meet the CRAN directive to avoid stopping if a web +resource is unavailable.
  • +
  • Improved error messages in table_load() and +table_save().
  • +
  • Removed table_export(). Use table_save() +instead.
@@ -212,8 +241,12 @@

MazamaLocationUtils 0.2.6 Unreleased

    -
  • Removed ~APIKey() functionality. Now importing this from MazamaCoreUtils 0.4.10.
  • -
  • Optimized table_getLocationID() and table_getNearestDistance() by only calculating distance for unique locations. This helps tremendously when longitude and latitude come from “tidy” dataframes.
  • +
  • Removed ~APIKey() functionality. Now importing this +from MazamaCoreUtils 0.4.10.
  • +
  • Optimized table_getLocationID() and +table_getNearestDistance() by only calculating distance for +unique locations. This helps tremendously when longitude +and latitude come from “tidy” dataframes.
@@ -221,7 +254,8 @@

MazamaLocationUtils 0.2.5 Unreleased

@@ -237,7 +271,9 @@

MazamaLocationUtils 0.2.3 Unreleased

@@ -245,13 +281,21 @@

MazamaLocationUtils 0.2.2 Unreleased

    -
  • Rename county to countyName. (This change more closely matches spatial metadata found in other systems and fits with the pattern of ~Code/~Name pairs in MazamaSpatialUtils as is the case with countryCode/CountryName and stateCode/stateName.)
  • +
  • Rename county to countyName. (This change +more closely matches spatial metadata found in other systems and fits +with the pattern of ~Code/~Name pairs in +MazamaSpatialUtils as is the case with +countryCode/CountryName and +stateCode/stateName.)
  • Regenerated example datasets.
  • Updated tests to reflect regenerated example datasets.
  • -
  • Fixed bug in table_findAdjacentDistances() when only two locations are adjacent.
  • -
  • Re-exporting location validation functions from MazamaCoreUtils.
  • +
  • Fixed bug in table_findAdjacentDistances() when only +two locations are adjacent.
  • +
  • Re-exporting location validation functions from +MazamaCoreUtils.
  • -table_updateColumn() now ignores NA values in locationID.
  • +table_updateColumn() now ignores NA values +in locationID.
@@ -259,7 +303,9 @@

MazamaLocationUtils 0.2.1 Unreleased

@@ -267,20 +313,39 @@

MazamaLocationUtils 0.2.0 2021-10-05

-

Version 0.2.x focuses on usability improvements after initial work with the package.

+

Version 0.2.x focuses on usability improvements after initial work +with the package.

@@ -296,12 +361,20 @@

MazamaLocationUtils 0.1.12 Unreleased

    -
  • Updated location_getSingleAddress_Photon() to remove revgeo dependency.
  • -
  • Updated to require geodist 0.0.6.007 to handle errors finding longitude and latitude columns in the passed in tibble.
  • +
  • Updated location_getSingleAddress_Photon() to remove +revgeo dependency.
  • +
  • Updated to require geodist 0.0.6.007 to handle +errors finding longitude and latitude columns in the passed in +tibble.
  • -geodist::geodist() is now always called with measure = "geodesic" to avoid warning messages from geodist() about inaccuracies with measure = "cheap" (the geodist() default).
  • +geodist::geodist() is now always called with +measure = "geodesic" to avoid warning messages from +geodist() about inaccuracies with +measure = "cheap" (the geodist() +default).
  • -mazama_initialize() now installs required datasets if they are missing.
  • +mazama_initialize() now installs required datasets if +they are missing.
  • Updated to require MazamaSpatialUtils 0.7.
@@ -310,7 +383,8 @@

MazamaLocationUtils 0.1.11 Unreleased

    -
  • Added unit test for table_findOverlappingLocations().
  • +
  • Added unit test for +table_findOverlappingLocations().
@@ -318,9 +392,16 @@

MazamaLocationUtils 0.1.10 Unreleased

    -
  • Added table_initializeExisting() for fast conversion of an existing table of spatial metadata into a standardized “known location” table.
  • -
  • Added table_findOverlappingLocations() to help choose an appropriate radius when initializing from an existing metadata table.
  • -
  • Added addressService argument to table_addLocation(), table_addSingleLocation() andlocation_initialize()` to skip the address step that requires web services.
  • +
  • Added table_initializeExisting() for fast conversion of +an existing table of spatial metadata into a standardized “known +location” table.
  • +
  • Added table_findOverlappingLocations() to help choose +an appropriate radius when initializing from an existing metadata +table.
  • +
  • Added addressService argument to +table_addLocation(), +table_addSingleLocation() andlocation_initialize()` to skip +the address step that requires web services.
@@ -345,7 +426,8 @@

MazamaLocationUtils 0.1.7 Unreleased

@@ -353,7 +435,8 @@

MazamaLocationUtils 0.1.6 2019-11-20

    -
  • Updated checks and explicit instructions for installing required spatial data.
  • +
  • Updated checks and explicit instructions for installing required +spatial data.
@@ -361,7 +444,8 @@

MazamaLocationUtils 0.1.5 Unreleased

    -
  • Changed examples from \code{\dontrun} to \code{\donttest} per CRAN suggestion.
  • +
  • Changed examples from \code{\dontrun} to \code{\donttest} per CRAN +suggestion.
@@ -396,7 +480,8 @@

  • Removed getLoations()
  • -
  • Added getLocationID() and getNearestLocation() +
  • Added getLocationID() and +getNearestLocation()
  • Various cleanup/refactor
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 403dd2b..33cc7b5 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,7 +1,7 @@ -pandoc: 2.11.4 +pandoc: 2.17.1.1 pkgdown: 1.6.1 pkgdown_sha: ~ articles: MazamaLocationUtils: MazamaLocationUtils.html -last_built: 2022-05-06T18:49Z +last_built: 2022-07-14T18:53Z diff --git a/docs/reference/LocationDataDir.html b/docs/reference/LocationDataDir.html index 52ed9b4..3aa5ea7 100644 --- a/docs/reference/LocationDataDir.html +++ b/docs/reference/LocationDataDir.html @@ -75,7 +75,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7

diff --git a/docs/reference/MazamaLocationUtils.html b/docs/reference/MazamaLocationUtils.html index ea1412b..ab0ef2b 100644 --- a/docs/reference/MazamaLocationUtils.html +++ b/docs/reference/MazamaLocationUtils.html @@ -77,7 +77,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/coreMetadataNames.html b/docs/reference/coreMetadataNames.html index 158f77f..aaf7c5f 100644 --- a/docs/reference/coreMetadataNames.html +++ b/docs/reference/coreMetadataNames.html @@ -73,7 +73,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/getAPIKey.html b/docs/reference/getAPIKey.html index 8089772..0cfc7e7 100644 --- a/docs/reference/getAPIKey.html +++ b/docs/reference/getAPIKey.html @@ -72,7 +72,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/getLocationDataDir.html b/docs/reference/getLocationDataDir.html index 4f7e112..9a7f106 100644 --- a/docs/reference/getLocationDataDir.html +++ b/docs/reference/getLocationDataDir.html @@ -72,7 +72,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/id_monitors_500.html b/docs/reference/id_monitors_500.html index 33fc94f..c362522 100644 --- a/docs/reference/id_monitors_500.html +++ b/docs/reference/id_monitors_500.html @@ -95,7 +95,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/index.html b/docs/reference/index.html index df150df..0621e47 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -71,7 +71,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/location_createID.html b/docs/reference/location_createID.html index feb299e..ffb8f61 100644 --- a/docs/reference/location_createID.html +++ b/docs/reference/location_createID.html @@ -74,7 +74,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/location_getCensusBlock.html b/docs/reference/location_getCensusBlock.html index fba53c4..de2da5f 100644 --- a/docs/reference/location_getCensusBlock.html +++ b/docs/reference/location_getCensusBlock.html @@ -79,7 +79,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/location_getOpenCageInfo.html b/docs/reference/location_getOpenCageInfo.html index 2a08625..ceff4ba 100644 --- a/docs/reference/location_getOpenCageInfo.html +++ b/docs/reference/location_getOpenCageInfo.html @@ -75,7 +75,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/location_getSingleAddress_Photon.html b/docs/reference/location_getSingleAddress_Photon.html index 5d719e4..ebc711a 100644 --- a/docs/reference/location_getSingleAddress_Photon.html +++ b/docs/reference/location_getSingleAddress_Photon.html @@ -89,7 +89,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/location_getSingleAddress_TexasAM.html b/docs/reference/location_getSingleAddress_TexasAM.html index aa6e3fb..b29b697 100644 --- a/docs/reference/location_getSingleAddress_TexasAM.html +++ b/docs/reference/location_getSingleAddress_TexasAM.html @@ -73,7 +73,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/location_getSingleElevation_USGS.html b/docs/reference/location_getSingleElevation_USGS.html index 6451a29..0827983 100644 --- a/docs/reference/location_getSingleElevation_USGS.html +++ b/docs/reference/location_getSingleElevation_USGS.html @@ -73,7 +73,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/location_initialize.html b/docs/reference/location_initialize.html index 78e009b..034e167 100644 --- a/docs/reference/location_initialize.html +++ b/docs/reference/location_initialize.html @@ -88,7 +88,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/mazama_initialize.html b/docs/reference/mazama_initialize.html index 656deaa..a6fc323 100644 --- a/docs/reference/mazama_initialize.html +++ b/docs/reference/mazama_initialize.html @@ -82,7 +82,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/or_monitors_500.html b/docs/reference/or_monitors_500.html index a4ab71c..f77b942 100644 --- a/docs/reference/or_monitors_500.html +++ b/docs/reference/or_monitors_500.html @@ -95,7 +95,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/pipe.html b/docs/reference/pipe.html index c3864af..0a47acc 100644 --- a/docs/reference/pipe.html +++ b/docs/reference/pipe.html @@ -72,7 +72,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/setAPIKey.html b/docs/reference/setAPIKey.html index 6d56142..f22468c 100644 --- a/docs/reference/setAPIKey.html +++ b/docs/reference/setAPIKey.html @@ -72,7 +72,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/setLocationDataDir.html b/docs/reference/setLocationDataDir.html index 1afde16..7c34817 100644 --- a/docs/reference/setLocationDataDir.html +++ b/docs/reference/setLocationDataDir.html @@ -73,7 +73,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/showAPIKeys.html b/docs/reference/showAPIKeys.html index 7d8d636..00ee3a8 100644 --- a/docs/reference/showAPIKeys.html +++ b/docs/reference/showAPIKeys.html @@ -72,7 +72,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_addColumn.html b/docs/reference/table_addColumn.html index b1ce3d4..2e8a44a 100644 --- a/docs/reference/table_addColumn.html +++ b/docs/reference/table_addColumn.html @@ -74,7 +74,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_addCoreMetadata.html b/docs/reference/table_addCoreMetadata.html index ecb4721..7ad67ee 100644 --- a/docs/reference/table_addCoreMetadata.html +++ b/docs/reference/table_addCoreMetadata.html @@ -98,7 +98,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_addLocation.html b/docs/reference/table_addLocation.html index da4490c..e745fca 100644 --- a/docs/reference/table_addLocation.html +++ b/docs/reference/table_addLocation.html @@ -75,7 +75,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_addOpenCageInfo.html b/docs/reference/table_addOpenCageInfo.html index 5ab66f7..fdbaa29 100644 --- a/docs/reference/table_addOpenCageInfo.html +++ b/docs/reference/table_addOpenCageInfo.html @@ -92,7 +92,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_addSingleLocation.html b/docs/reference/table_addSingleLocation.html index 4f9960a..480d3cb 100644 --- a/docs/reference/table_addSingleLocation.html +++ b/docs/reference/table_addSingleLocation.html @@ -75,7 +75,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_filterByDistance.html b/docs/reference/table_filterByDistance.html index 40871da..c84e904 100644 --- a/docs/reference/table_filterByDistance.html +++ b/docs/reference/table_filterByDistance.html @@ -74,7 +74,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_findAdjacentDistances.html b/docs/reference/table_findAdjacentDistances.html index ae875b6..f88943b 100644 --- a/docs/reference/table_findAdjacentDistances.html +++ b/docs/reference/table_findAdjacentDistances.html @@ -78,7 +78,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_findAdjacentLocations.html b/docs/reference/table_findAdjacentLocations.html index 6a1586c..e7bd631 100644 --- a/docs/reference/table_findAdjacentLocations.html +++ b/docs/reference/table_findAdjacentLocations.html @@ -78,7 +78,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_getDistanceFromTarget.html b/docs/reference/table_getDistanceFromTarget.html index 4159769..a3b2859 100644 --- a/docs/reference/table_getDistanceFromTarget.html +++ b/docs/reference/table_getDistanceFromTarget.html @@ -75,7 +75,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_getLocationID.html b/docs/reference/table_getLocationID.html index 98edb4c..033a49e 100644 --- a/docs/reference/table_getLocationID.html +++ b/docs/reference/table_getLocationID.html @@ -76,7 +76,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_getNearestDistance.html b/docs/reference/table_getNearestDistance.html index 7a504b5..2f874d8 100644 --- a/docs/reference/table_getNearestDistance.html +++ b/docs/reference/table_getNearestDistance.html @@ -79,7 +79,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_getNearestLocation.html b/docs/reference/table_getNearestLocation.html index d0db3d6..ffeab9d 100644 --- a/docs/reference/table_getNearestLocation.html +++ b/docs/reference/table_getNearestLocation.html @@ -76,7 +76,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_getRecordIndex.html b/docs/reference/table_getRecordIndex.html index 7dc2458..47cb251 100644 --- a/docs/reference/table_getRecordIndex.html +++ b/docs/reference/table_getRecordIndex.html @@ -73,7 +73,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_initialize.html b/docs/reference/table_initialize.html index bf1d561..2778dcd 100644 --- a/docs/reference/table_initialize.html +++ b/docs/reference/table_initialize.html @@ -89,7 +89,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_initializeExisting.html b/docs/reference/table_initializeExisting.html index eb70665..f927748 100644 --- a/docs/reference/table_initializeExisting.html +++ b/docs/reference/table_initializeExisting.html @@ -102,7 +102,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_leaflet.html b/docs/reference/table_leaflet.html index 24e2106..d36c477 100644 --- a/docs/reference/table_leaflet.html +++ b/docs/reference/table_leaflet.html @@ -75,7 +75,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_leafletAdd.html b/docs/reference/table_leafletAdd.html index 20b0e59..467cff7 100644 --- a/docs/reference/table_leafletAdd.html +++ b/docs/reference/table_leafletAdd.html @@ -75,7 +75,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_load.html b/docs/reference/table_load.html index 34f5b26..5be1a0f 100644 --- a/docs/reference/table_load.html +++ b/docs/reference/table_load.html @@ -76,7 +76,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_removeColumn.html b/docs/reference/table_removeColumn.html index e47d2e9..e07e2fb 100644 --- a/docs/reference/table_removeColumn.html +++ b/docs/reference/table_removeColumn.html @@ -73,7 +73,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_removeRecord.html b/docs/reference/table_removeRecord.html index c6fbb7c..b6e0e3f 100644 --- a/docs/reference/table_removeRecord.html +++ b/docs/reference/table_removeRecord.html @@ -73,7 +73,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/table_save.html b/docs/reference/table_save.html index 9b0bf99..efa059f 100644 --- a/docs/reference/table_save.html +++ b/docs/reference/table_save.html @@ -72,7 +72,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 @@ -179,7 +179,7 @@

Examp # Check the locationDataDir list.files(getLocationDataDir(), pattern = "table_save_example") -
#> [1] "table_save_example.2022-05-06T11:50:40.rda" +
#> [1] "table_save_example.2022-07-14T11:54:17.rda" #> [2] "table_save_example.rda"
diff --git a/docs/reference/table_updateColumn.html b/docs/reference/table_updateColumn.html index 9d1a213..d590138 100644 --- a/docs/reference/table_updateColumn.html +++ b/docs/reference/table_updateColumn.html @@ -40,9 +40,13 @@ - + @@ -74,7 +78,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 @@ -122,9 +126,13 @@

Update a column of metadata in a table

-

For matching locationID, records the associated -locationData is used to replace any existing value in columnName. -NA values in locationID will be ignored.

+

Updates records in a location table. Records are identified +by locationID and the data found in locationData is used to +replace any existing value in the columnName column. +locationID and locationData must be of the same length. +Any NA values in locationID will be ignored.

+

If columnName is not a named column within locationTbl, a new +column will be created.

table_updateColumn(
@@ -144,7 +152,8 @@ 

Arg columnName -

Name to use for the new column.

+

Name of an existing/new column in locationTbl whose data +will be updated/created.

locationID @@ -152,7 +161,8 @@

Arg locationData -

Vector of data to used at matching records.

+

Vector of data to be inserted at records identified by +locationID.

verbose diff --git a/docs/reference/table_updateSingleRecord.html b/docs/reference/table_updateSingleRecord.html index e2c95c9..17db282 100644 --- a/docs/reference/table_updateSingleRecord.html +++ b/docs/reference/table_updateSingleRecord.html @@ -76,7 +76,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/validateLocationTbl.html b/docs/reference/validateLocationTbl.html index 7682888..e181637 100644 --- a/docs/reference/validateLocationTbl.html +++ b/docs/reference/validateLocationTbl.html @@ -73,7 +73,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/validateLonLat.html b/docs/reference/validateLonLat.html index 656afa1..53a5bf3 100644 --- a/docs/reference/validateLonLat.html +++ b/docs/reference/validateLonLat.html @@ -77,7 +77,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/validateLonsLats.html b/docs/reference/validateLonsLats.html index fe9073a..326ff58 100644 --- a/docs/reference/validateLonsLats.html +++ b/docs/reference/validateLonsLats.html @@ -77,7 +77,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/validateMazamaSpatialUtils.html b/docs/reference/validateMazamaSpatialUtils.html index 14d0d37..823a93b 100644 --- a/docs/reference/validateMazamaSpatialUtils.html +++ b/docs/reference/validateMazamaSpatialUtils.html @@ -74,7 +74,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/wa_airfire_meta.html b/docs/reference/wa_airfire_meta.html index 83d4df7..87a9c06 100644 --- a/docs/reference/wa_airfire_meta.html +++ b/docs/reference/wa_airfire_meta.html @@ -85,7 +85,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/docs/reference/wa_monitors_500.html b/docs/reference/wa_monitors_500.html index 85c2c13..80e0029 100644 --- a/docs/reference/wa_monitors_500.html +++ b/docs/reference/wa_monitors_500.html @@ -95,7 +95,7 @@ MazamaLocationUtils - 0.3.6 + 0.3.7 diff --git a/man/table_updateColumn.Rd b/man/table_updateColumn.Rd index d589b3b..35efa20 100644 --- a/man/table_updateColumn.Rd +++ b/man/table_updateColumn.Rd @@ -15,11 +15,13 @@ table_updateColumn( \arguments{ \item{locationTbl}{Tibble of known locations.} -\item{columnName}{Name to use for the new column.} +\item{columnName}{Name of an existing/new column in \code{locationTbl} whose data +will be updated/created.} \item{locationID}{Vector of \code{locationID} strings.} -\item{locationData}{Vector of data to used at matching records.} +\item{locationData}{Vector of data to be inserted at records identified by +\code{locationID}.} \item{verbose}{Logical controlling the generation of progress messages.} } @@ -27,9 +29,14 @@ table_updateColumn( Updated tibble of known locations. } \description{ -For matching \code{locationID}, records the associated -\code{locationData} is used to replace any existing value in \code{columnName}. -\code{NA} values in \code{locationID} will be ignored. +Updates records in a location table. Records are identified +by \code{locationID} and the data found in \code{locationData} is used to +replace any existing value in the \code{columnName} column. +\code{locationID} and \code{locationData} must be of the same length. +Any \code{NA} values in \code{locationID} will be ignored. + +If \code{columnName} is not a named column within \code{locationTbl}, a new +column will be created. } \examples{ library(MazamaLocationUtils) diff --git a/tests/testthat/test-table_updateColumn.R b/tests/testthat/test-table_updateColumn.R index 6255a2b..d102dd8 100644 --- a/tests/testthat/test-table_updateColumn.R +++ b/tests/testthat/test-table_updateColumn.R @@ -21,6 +21,7 @@ test_that("table_updateColumn() works with data", { locationID <- table_getLocationID(locationTbl, wa_sub$longitude, wa_sub$latitude, distanceThreshold = 1000) locationData <- wa_sub$siteName + # Create a new column testTbl <- table_updateColumn(locationTbl, "siteName", locationID, locationData) testTbl_indices <- table_getRecordIndex(testTbl, locationID) @@ -34,3 +35,28 @@ test_that("table_updateColumn() works with data", { }) +test_that("table_updateColumn() skips unknown locations", { + + locationTbl <- get(data("wa_monitors_500")) + wa <- get(data("wa_airfire_meta")) + + # Record indices into for wa + wa_indices <- seq(5,65,5) + wa_sub <- wa[wa_indices,] + + # NOTE: Include locationIDs not found in locationTbl + locationID <- c("locationID_NOT_FOUND", table_getLocationID(locationTbl, wa_sub$longitude, wa_sub$latitude, distanceThreshold = 1000)) + locationData <- c("locationData_NOT_FOUND", wa_sub$siteName) + + # update an Existing column + testTbl <- table_updateColumn(locationTbl, "locationName", locationID, locationData) + testTbl_indices <- + table_getRecordIndex(testTbl, locationID) %>% + na.omit() %>% as.numeric() + + expect_true({ + all( testTbl$locationName[testTbl_indices] %in% wa$siteName ) + }) + +}) +