Ok thank you for chiming in. I used the "st_read" function which I have been using on similar data for weeks. The "st_write" function used to work but I have included the relevant code to illustrate my issue. The error message is at the end. Please advise and let me know how I can you "help you help me"
#Prepare all necessary or useful librairies
DaisyDuck <- c("sf","ggplot2","rstudioapi", "DescTools", "tibble",
"readr", "ggspatial", "ggmap","rgdal", "rgeos","maptools",
"GISTools", "dplyr", "tmap", "leaflet", "raster", "sp", "tidyverse")
#Load in all librairies at once
lapply(DaisyDuck, library, character.only = TRUE)
#Read in shapefile for complete study area by directory path
RF12067 <- st_read("H:\\VentilationUnits\\CombinedRoofFans\\ComboRF.shp")
#Begin cleaning data some of which is necessary from flawed GIS shapefile join
RF12067$TDS_NUM <- StrLeft(RF12067$LOCATION_C,3)
#Transforms coordinates of simple features dataframe based on certain projection and assigned to new object
RF12067_1 <- st_transform(RF12067, "+proj=longlat +ellps=WGS84 +datum=WGS84")
#Rearrange column order
FinalRF12067 <- RF12067_1[c("BOROUGH","DEVELOPMEN", "BLDG_NUM","TDS_NUM","LOCATION_C", "geometry")]
#Conversion of data type from factor to character for easier grouping
FinalRF12067$BLDG_NUM <- as.character(FinalRF12067$BLDG_NUM)
FinalRF12067$LOCATION_C <- as.character(FinalRF12067$LOCATION_C)
FinalRF12067$TDS_NUM <- as.character(FinalRF12067$TDS_NUM)
#Create a new column for each row representing an individual roof fan; it appends the tenant data system
#code to a period and to the last 2 digits of the "Bldg_Num"
FinalRF12067$NYCHA_BldgCode <-paste(FinalRF12067$TDS_NUM, sep = ".", StrRight(FinalRF12067$BLDG_NUM, 2))
#Create a table in which roof fan features are grouped by its' corresponding building code
LocationCount <- count(FinalRF12067, vars = NYCHA_BldgCode)
#Read column names and check datatype to prepare for cleaning and improved readability
#Change the column names
names(LocationCount) <- "NYCHA_BldgCode"
names(LocationCount) <- "No_RoofFans"
#Verify the datatype of each column
#For each column, concatenate with a comma between each element to prepare new dataframe in which
#the roof fan counts are iterated individually to it's respective NYCHA property building
paste0(LocationCount$NYCHA_BldgCode, collapse = ",")
paste0(LocationCount$No_RoofFans, collapse = ",")
#Establish dataframe object with essential vectors from 'LocationCount' columns
LocationStringSet = data.frame(LocationCount$NYCHA_BldgCode, LocationCount$No_RoofFans)
#Assign name to dataframe for function that takes columns of NYCHA building
#and respective roof counts and creates a new list-columns
NYCHA_RF_LocationString = map2_df(LocationCount$NYCHA_BldgCode, LocationCount$No_RoofFans,
~data.frame(LocationCount.NYCHA_BldgCode=.x, LocationCount.No_RoofFans=.y, new.var=paste(.x, 1:.y, sep = ".RF")))
There were 50 or more warnings (use warnings() to see the first 50)
#Read out column names to begin improving readability
names(NYCHA_RF_LocationString) <- "RoofFanUniqueID"
names(NYCHA_RF_LocationString) <- "NYCHA_BldgCode"
names(NYCHA_RF_LocationString) <- "RoofFanCt"
#Complete join that returns all rows of 1 table containing shapefile data
#and the other table of corresponding NYCHA rooftop codes while filtering out enormous amount of duplicates
NYCHA_TotalCode <- merge(x= NYCHA_RF_LocationString, y= FinalRF12067[!duplicated (FinalRF12067$NYCHA_BldgCode),], by = "NYCHA_BldgCode", all.x= TRUE)
#Write to a shapefile
>Writing layer `NYCHArf_TotalCode' to data source `NYCHArf_TotalCode.shp' using driver `ESRI Shapefile'
Creating layer NYCHArf_TotalCode failed.
Error in CPL_write_ogr(obj, dsn, layer, driver, as.character(dataset_options), :
Layer creation failed.
In addition: Warning messages:
1: In abbreviate_shapefile_names(obj) :
Field names abbreviated for ESRI Shapefile driver
2: In CPL_write_ogr(obj, dsn, layer, driver, as.character(dataset_options), :
GDAL Error 6: Geometry type of `3D Point' not supported in shapefiles. Type can be overridden with a layer creation option of SHPT=POINT/ARC/POLYGON/MULTIPOINT/POINTZ/ARCZ/POLYGONZ/MULTIPOINTZ/MULTIPATCH.