как я могу преобразовать нормальный фрейм данных в фрейм данных пространственной точки?Это строки кода, которые я использовал, но получил эту ошибку:
Error in if (more || nchar(output) > 80) { :
missing value where TRUE/FALSE needed
// Код:
coords <- FinalOlistDataset[ , c("avg_lng", "avg_lat")]
data <- FinalOlistDataset[ , 1:9]
crs <- CRS("+init=epsg:3414")
FinalOlistDatasetSPDF <- SpatialPointsDataFrame(coords = coords,
data = data,
proj4string = crs)
введите описание изображения здесь
вот мой вывод с dput (head (FinalOlistDataset)):
structure(list(order_id = c("e481f51cbdc54678b7cc49136f2d6af7",
"e69bfb5eb88e0ed6a785585b27e16dbf", "34513ce0c4fab462a55830c0989c7edb",
"85ce859fd6dc634de8d2f1e290444043", "203096f03d82e0dffbc41ebc2e2bcfb7",
"f70a0aff17df5a6cdd9a7196128bd354"), customer_id = c("9ef432eb6251297304e76186b10a928d",
"31ad1d1b63eb9962463f764d4e6e0c9d", "7711cf624183d843aafe81855097bc37",
"059f7fc5719c7da6cbafe370971a8d70", "d2b091571da224a1b36412c18bc3bbfe",
"456dc10730fbdba34615447ea195d643"), order_purchase_timestamp = structure(c(1506941793,
1501329302, 1499975891, 1511222621, 1505745090, 1502366313), class = c("POSIXct",
"POSIXt"), tzone = "UTC"), price = c(29.99, 149.99, 98, 17.9,
109.9, 279), freight_value = c(8.72, 19.77, 16.13, 11.85, 8.96,
34.19), customer_unique_id = c("7c396fd4830fd04220f754e42b4e5bff",
"299905e3934e9e181bfb2e164dd4b4f8", "782987b81c92239d922aa49d6bd4200b",
"d0ff1a7468fcc46b8fc658ab35d2a12c", "d699688533772c15a061e8ce81cb56df",
"1974875b4a1d2e2ee6d586e3ba4d7602"), geolocation_zip_code_prefix = c(3149,
18075, 4278, 13186, 4001, 5634), customer_city = c("sao paulo",
"sorocaba", "sao paulo", "hortolandia", "sao paulo", "sao paulo"
), customer_state = c("SP", "SP", "SP", "SP", "SP", "SP"), avg_lng = c(-46.58716127625,
-47.4673971464706, -46.608909625125, -47.1989801198462, -46.6511147760169,
-46.7374914230303), avg_lat = c(-23.5769829333333, -23.4740303493464,
-23.601855984125, -22.8899823605, -23.5729394801695, -23.6063754424242
)), .Names = c("order_id", "customer_id", "order_purchase_timestamp",
"price", "freight_value", "customer_unique_id", "geolocation_zip_code_prefix",
"customer_city", "customer_state", "avg_lng", "avg_lat"), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))