Issues with writing a dataframe to a shapefile

Hi, it's hard to provide much specific help without a complete reproducible example, called a reprex. I do have a suggestion, however.

The sf (simple features) successor to the spatial package makes geometries much easier than dealing with shapefiles. In particular, they are data frames, with the geometry as one column. While sf can import properly formatted csv data, I don't see any direct export to shapefile function, so it may not work for you.