Skip to content

delete shapefile in the directory

3 messages · gianni lavaredo, Agustin Lobo, Paul Hiemstra

#
system()
lets you run any command on your OS
Agus
gianni lavaredo wrote:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alobolistas.vcf
Type: text/x-vcard
Size: 251 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090320/43f46e69/attachment.vcf>
2 days later
#
Hi,

You can also use the command file.remove. The advantage of using this 
command in stead of the system call that Agustin suggested is that the 
code will work on all OS'es. If you use a call like system("rm 
/foo/bar") this works on Linux but not on Windows.

In addition, shapefiles are ofcourse a collection of files. You can use 
file.remove in combination with list.files to delete all the files that 
form a shapefile. If the base name of the shapefile is foo_bar:

file.remove(list.files(pattern="foo_bar"))

cheers
Paul
Agustin Lobo wrote: