Get lat lon columns (or create them from geocoding addresses), and clean up those columns in a data.frame
Source:R/latlon_df_clean.R
latlon_df_clean.Rd
Utility to identify lat and lon columns (or addresses), renaming and cleaning them up.
Arguments
- df
data.frame With columns lat and lon or names that can be interpreted as such, or addresses that can be geocoding to create lat lon columns
- invalid_msg_table
Set to TRUE to add columns "valid" and "invalid_msg" to output
- set_invalid_to_na
if not set FALSE, it replaces invalid lat or lon with NA values
Value
Returns the same data.frame but with relevant colnames changed to lat and lon, or lat,lon added based on addresses, and invalid lat or lon values cleaned up if possible or else replaced with NA, and optional columns "valid" and "invalid_msg"
Details
Tries to figure out which columns seem to have lat lon values, or addresses that can be converted to lat lon columns, renames those in the data.frame. Cleans up lat and lon values (removes extra characters, makes numeric)