% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/table_updateColumn.R
\name{table_updateColumn}
\alias{table_updateColumn}
\title{Update a column of metadata in a table}
\usage{
table_updateColumn(
  locationTbl = NULL,
  columnName = NULL,
  locationID = NULL,
  locationData = NULL,
  verbose = TRUE
)
}
\arguments{
\item{locationTbl}{Tibble of known locations.}

\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 be inserted at records identified by
\code{locationID}.}

\item{verbose}{Logical controlling the generation of progress messages.}
}
\value{
Updated tibble of known locations.
}
\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.
}
\examples{
library(MazamaLocationUtils)

locationTbl <- get(data("wa_monitors_500"))
wa <- get(data("wa_airfire_meta"))

# We will merge some metadata from wa into locationTbl

# Record indices for wa
wa_indices <- seq(5,65,5)
wa_sub <- wa[wa_indices,]

locationID <- 
  table_getLocationID(
    locationTbl, 
    wa_sub$longitude, 
    wa_sub$latitude, 
    distanceThreshold = 500
  )
  
locationData <- wa_sub$AQSID

locationTbl <- 
  table_updateColumn(locationTbl, "AQSID", locationID, locationData)

# Look at the data we attempted to merge
wa$AQSID[wa_indices]

# And two columns from the updated locationTbl
locationTbl_indices <- table_getRecordIndex(locationTbl, locationID)
locationTbl[locationTbl_indices, c("city", "AQSID")]

}
\seealso{
\code{\link[=table_addColumn]{table_addColumn()}}

\code{\link[=table_removeColumn]{table_removeColumn()}}
}
