在SQL数据库的SQL列中编码S4对象的最佳方法是什么(使用MariaDB,但希望可以与其他SQL数据库一起使用)?
我正在使用R传单在R Shiny中定义多边形。例如:
> dput(my_region)
new("SpatialPolygons", polygons = list(new("Polygons", Polygons = list(
new("Polygon", labpt = c(145.123615916206, -38.1380707008379
), area = 0.000203493634000019, hole = FALSE, ringDir = 1L,
coords = structure(c(145.116767, 145.135218, 145.131957,
145.11136, 145.116767, -38.132937, -38.132329, -38.142388,
-38.144278, -38.132937), .Dim = c(5L, 2L), .Dimnames = list(
NULL, c("x", "y"))))), plotOrder = 1L, labpt = c(145.123615916206,
-38.1380707008379), ID = "1", area = 0.000203493634000019)),
plotOrder = 1L, bbox = structure(c(145.11136, -38.144278,
145.135218, -38.132329), .Dim = c(2L, 2L), .Dimnames = list(
c("x", "y"), c("min", "max"))), proj4string = new("CRS",
projargs = NA_character_))
但是,如果我尝试as.character(my_region)
尝试将其编码为字符串,则会出现错误:
Error in as.character.default(my_region) :
no method for coercing this S4 class to a vector
目的是将该对象存储在数据库列中,以便在使用Shiny应用程序时可以读取/覆盖该对象。