[R] meta characters in file path

Li,Qinghong,ST.LOUIS,Molecular Biology Qinghong.Li at rdmo.nestle.com
Fri Aug 4 22:05:37 CEST 2006


thanks Prof Ripley. dir() returns the path with full names (wildcards replaced) that are exactly what I need.



-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Prof Brian Ripley
Sent: Friday, August 04, 2006 12:27 PM
To: Li,Qinghong,ST.LOUIS,Molecular Biology
Cc: r-help at stat.math.ethz.ch; Tony Plate
Subject: Re: [R] meta characters in file path


On Fri, 4 Aug 2006, Li,Qinghong,ST.LOUIS,Molecular Biology wrote:

> Thanks. I tried them, it works for most of those characters except "*" 
> and "?".

Those are not valid characters in Windows file paths
(/  " * : < > ? \ | are invalid in file or dir names).

> Does regular expression work in file names in windows? 

No, and I think you may mean wildcards (which is what work on the command 
line).

> e.g. I have a machine-generated file named "021706 matrix#1479 @50.csv", 
> of which "1479" is kinda random. Will I be able to match "1479" with 
> some sort of "wild card" chars?

Yes, use dir(), with regexp pattern patching to find the name(s) you 
want.  glob2rx() might be useful here.

> Thanks
> Johnny
> 
> -----Original Message-----
> From: Tony Plate [mailto:tplate at acm.org]
> Sent: Thursday, August 03, 2006 3:42 PM
> To: Li,Qinghong,ST.LOUIS,Molecular Biology
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] meta characters in file path
> 
> 
> What is the problem you are having?  Seems to work fine for me running 
> under Windows2000:
> 
>  > write.table(data.frame(a=1:3,b=4:6), file="@# x.csv", sep=",")
>  > read.csv(file="@# x.csv")
>    a b
> 1 1 4
> 2 2 5
> 3 3 6
>  > sessionInfo()
> Version 2.3.1 (2006-06-01)
> i386-pc-mingw32
> 
> attached base packages:
> [1] "methods"   "stats"     "graphics"  "grDevices" "utils"     "datasets"
> [7] "base"
> 
> other attached packages:
>       XML
> "0.99-8"
>  >
> 
> Li,Qinghong,ST.LOUIS,Molecular Biology wrote:
> > Hi,
> > 
> > I need to read in some files. The file names contain come meta characters such as @, #, and white spaces etc, In read.csv, file= option, is there any way that one can make the function to recognize a file path with those characters?
> > 
> > Thanks
> > Johnny
> > 
> > 	[[alternative HTML version deleted]]
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list