This isn't a huge deal, but does anyone know why:
readOGR('~/documents/zipcodes', 'zipcodes')
Returns: "Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : Cannot open file"
When this:
setwd('~/documents/zipcodes')
readOGR('.', 'zipcodes')
Works perfectly?
you can either use
tools::file_path_as_absolute()
like this:or
path.expand()
as hrbrmstr mentioned in his comment:Another, more inconvenient way would be to use
base::dirname()
in combination withpaste0()
: