I am trying to use the sf package to open a shape file in R (posit cloud) so I can randomly generate coordinates that fall inside of my polygon. My shape files are saved in My Documents and I have uploaded them to my project's cloud and can see them in the Files pane. They are called "daylily area.shp" and "daylily area.shx". The .proj is also saved there as well.
I am trying to use the code below to create an object called treatmentarea but keep getting the same error message: Error: dsn must point to a source, not an empty string. All of the things I've tried are below and give the same error:
treatmentarea <- st_read(system.file("daylily area.shx", package="sf"), quiet=TRUE)
treatmentarea <- st_read(system.file("C:/Users/User/Documents//daylily area.shx", package="sf"), quiet=TRUE)
treatmentarea <- st_read(system.file(dsn="C:Users/User/Documents", layer="daylily area.shp", package="sf"), quiet=TRUE)
mapfile <- read_sf("daylily area.shp")
treatmentarea <- st_read(system.file("mapfile/daylily area.shx", package="sf"), quiet=TRUE)
I found this post (https://www.reddit.com/r/RStudio/comments/myfbrn/help_with_sf_package/) having a similar issue, but apparently I'm still not naming my directory correct, I guess?
I am really lost trying to understand how to write the dsn correctly and have a really basic grasp on coding in general; any help to fix my code or help me understand my code would be appreciated.