Skip to content
Back to formatted view

Raw Message

Message-ID: <004401c4cbf2$fad82550$a3284e98@maths.soton.ac.uk>
Date: 2004-11-16T15:43:12Z
From: Roger Gill
Subject: deleting a file

Dear all,

I have a very simple question.  Simple, that is, if you know the answer.

I wish to delete a file in a given directory after having first checked its
existence.  I issue the following commands

path<-'c:example/R/'

Thus creating the directory.

indicator<-length(grep(filename,path))

If indicator is greater than zero then the file exists.  Now I wish to
remove this file.  However, I would like to make the code compatible for
Linux/Windows and Macs.

In Linux I would issue the command

system('rm paste(path,'filename',sep='')')

and this works just fine.  It does not however work for windows, and I have
no idea whether it would work on a mac.

Is there a single command thay escapes me?

Best Wishes

Roger Gill