EDIT: I see your secondary issue now; it looks like neither sf
nor sp
look at the <ExtendedData>
tags that hold the attribute data you want (open the KML in Notepad++ if you want to see what I mean). QGIS does detect and import them as separate attribute columns, so @Jella's advice is sound. I'm not sure if the issue here lies with sf
/sp
or GDAL, but it may be worth raising an issue of the sf
github page.
In the meantime, your instinct to go with tidyr
functions is sound, its just a little tricky to get a clean separation. The following looks pretty good:
asf_c_df <- st_set_geometry(asf_c, NULL) %>%
# remove duplicate <br> tags
dplyr::mutate(Description = gsub('<br><br>', '<br>', Description)) %>%
# split on <br>
tidyr::separate(., col = Description,
into = c('Date', 'Province', 'City', 'County', 'Location',
'Total_herd_size', 'Affected_animals', 'Deaths',
'Culled', 'Latitude', 'Longitude', 'Source'),
sep = '<br>') %>%
# ditch the key: part of key: value
dplyr::mutate_all(., funs(gsub('^.*: ', '', .))) %>%
# data type fixes
dplyr::mutate_at(vars(7:10), as.integer) %>%
dplyr::mutate_at(vars(11,12), as.numeric) %>%
# bonus points: proper dates. First, fix September, then cast to Date datatype
dplyr::mutate(Date = gsub('Sept', 'Sep', Date),
Date = as.POSIXct(Date, format = '%b %d, %Y'))