Hi, I have a dataframe column that consists of something closely resembling a python list of dictionaries as strings that contain coordinate points. I would like to parse these such that the output is a new data frame column in which each cell is a two-column matrix (for lat, long, respectively; sample below).
Has anyone come across something like this before? I'm a complete regex novice, so am not sure how to best approach this. Thanks!
path_id <- c("foo","bar")
path_shape <- c("[{\"lat\": 25.2, \"lng\": 55.4}, {\"lat\": 25.3, \"lng\": 55.3}]",
"[{\"lat\": 25.1, \"lng\": 55.4}, {\"lat\": 25.1, \"lng\": 55.3}, {\"lat\": 25.2, \"lng\": 55.3}, {\"lat\": 25.3, \"lng\": 55.4}]")
path_data <- data.frame(path_id, path_shape, stringsAsFactors=FALSE)
desired_outout_df_cell_sample <- matrix(data = c(25.2,25.3,55.4,55.3), ncol = 2)
desired_outout_df_cell_sample