Remove the column matching columnName
. This function
can be used in pipelines.
table_removeColumn(locationTbl = NULL, columnName = NULL, verbose = TRUE)
Tibble of known locations.
Name of the colun to be removed.
Logical controlling the generation of progress messages.
Updated tibble of known locations.
table_removeColumn
library(MazamaLocationUtils)
# Starting table
locationTbl <- get(data("wa_monitors_500"))
names(locationTbl)
#> [1] "locationID" "locationName" "longitude" "latitude" "elevation"
#> [6] "countryCode" "stateCode" "countyName" "timezone" "houseNumber"
#> [11] "street" "city" "postalCode"
# Add a new column
locationTbl <-
locationTbl %>%
table_addColumn("AQSID")
names(locationTbl)
#> [1] "locationID" "locationName" "longitude" "latitude" "elevation"
#> [6] "countryCode" "stateCode" "countyName" "timezone" "houseNumber"
#> [11] "street" "city" "postalCode" "AQSID"
# Now remove it
locationTbl <-
locationTbl %>%
table_removeColumn("AQSID")
names(locationTbl)
#> [1] "locationID" "locationName" "longitude" "latitude" "elevation"
#> [6] "countryCode" "stateCode" "countyName" "timezone" "houseNumber"
#> [11] "street" "city" "postalCode"
try({
# Cannot remove "core" metadata
locationTbl <-
locationTbl %>%
table_removeColumn("longitude")
}, silent = FALSE)
#> Error in table_removeColumn(., "longitude") :
#> columnName 'longitude' is part of the core metdata and cannot be removed