[R] meta characters in file path
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Aug 4 19:27:04 CEST 2006
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
> 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.
> -----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)
> attached base packages:
>  "methods" "stats" "graphics" "grDevices" "utils" "datasets"
>  "base"
> other attached packages:
> 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
> 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
More information about the R-help