Skip to content
Back to formatted view

Raw Message

Message-ID: <alpine.LFD.2.02.1104040658170.26686@gannet.stats.ox.ac.uk>
Date: 2011-04-04T06:06:16Z
From: Brian Ripley
Subject: detect filetype (as in unix 'file')
In-Reply-To: <1301886139248-3424562.post@n4.nabble.com>

On Sun, 3 Apr 2011, Jeroen Ooms wrote:

> Is there a way in R (in Linux) to detect the type of a file without invoking
> a shell? E.g to do this:
>
>> system("file density.plot")
> density.plot: PDF document, version 1.4
>
> but without using system()? I tried file() and file.info(), but both do
> display the information I am looking for.

No, but what is wrong with using system()?

'file' is large and complex because it tries to be comprehensive (but 
it still does not know about some common systems, e.g. 64-bit Windows 
binaries).  There simply is no point in replicating that in R: which 
is why we chose rather to port 'file' to Windows and provide in in 
Rools.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595