st_read()
function.If you want, you can try with your own data or download other shapefiles from https://www.naturalearthdata.com/
# if sf is not installed
# install.packages("sf")
library(sf)
# download the data
download.file("http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/physical/ne_10m_coastline.zip",
destfile = 'assets/data/coastlines.zip')
# unzip the file
unzip(zipfile = "assets/data/coastlines.zip",
exdir = 'assets/data/ne-coastlines-10m')
# WARNING: You have to define you own path in destfile argument and exdir.
# Read the file
coast <- read_sf("assets/data/ne-coastlines-10m")
Make a visual check of the spatial R object