## Not run:
# library(sp)
# data(meuse)
# coords <- SpatialPoints(meuse[, c("x", "y")])
# spdf <- SpatialPointsDataFrame(coords, meuse)
#
# ## Insert data in new database table
# pgInsert(conn, name = c("public", "meuse_data"), data.obj = spdf)
#
# ## The same command will insert into already created table (if all R
# ## columns match)
# pgInsert(conn, name = c("public", "meuse_data"), data.obj = spdf)
#
# ## If not all database columns match, need to use partial.match = TRUE
# colnames(spdf@data)[4] <- "cu"
# pgInsert(conn, name = c("public", "meuse_data"), data.obj = spdf,
# partial.match = TRUE)
# ## End(Not run)
Run the code above in your browser using DataLab