A couple things here: first, you can't write a shapefile to an ESRI geodatabase as only feature classes and feature datasets can be stored in there. Second, you can't write to geodatabases via sf
; you can only read them.
You have a couple of options. You can save your data as a shapefile (or any other spatial data format) outside of the geodatabase with sf
:
library(sf)
## it will guess the driver automatically based on the .shp extension
st_write(sf.object, "data/my_shapefile.shp")
Or, if you absolutely need to write in a geodatabase, you can use the arcgisbinding
library, but note you will need to be using a machine with an active ArcGIS license. Hence, this is a no-go on GNU/Linux and Mac.
I can't verify that this works since I am on GNU/Linux, but it should be something along these lines:
library(arcgisbinding)
arc.write("data.gdb/fc", sf.object)
Details on the R-ArcGIS Bridge (and the arcgisbinding
package) can be found here.