[R] Using the system command

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Sep 12 14:11:30 CEST 2003


On Fri, 12 Sep 2003, Barry Rowlingson wrote:

> Suzy Smith wrote:
> > Hello, I am currently taking a statistics course and we are to do a project producing a graph using multiple input files.
> >  
> > In R, I'm trying to build a filelist based on a pattern.  For some reason, if I do the command interactively and not assign it to an array variable I get what I thought I should, but if I do this inside my R program it chops off some file names and thinks there are two.
> >  
> > I looked on the R website and found that there is an 8,096 character limit when using a character array but mine chops at 119.
> >  
> > Here is the command:
> > filelist <- system(paste("ls ", INPUTFILES, sep=""),intern=T)
> >  
> > Any help would be much appreciated.
> >  
> 
>   I dont know why that doesn't work - it might be specific to the files 
> on your system. However, R has some functions for finding files, such as 
> list.files():

It was an undocumented limit on R < 1.6.2, so this is probably a long 
obselete version of R.

> 
>  > filelist <- list.files(pattern=".dat$")
>  > filelist
> [1] "jobacct.dat" "winmail.dat"
>  >
> 
>   Get more info by typing ?list.files
> 
>   The following functions may also be useful:
> 
> file.access(base)       Ascertain File Accessibility
> file.choose(base)       Choose a File Interactively
> file.info(base)         Extract File Information
> file.path(base)         Construct Path to File
> file.show(base)         Display One or More Files

-- 
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




More information about the R-help mailing list