An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110825/d1f1fcca/attachment.pl>
Construct a File Path: File Path Unknown
7 messages · Tyler Rinker, Jean V Adams, William Dunlap +2 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110825/6520b332/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110825/420c98f7/attachment.pl>
Try using normalizePath("foo.pdf") after creating
the file. It should return an absolute path to
an existing file.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Tyler Rinker
Sent: Thursday, August 25, 2011 12:43 PM
To: jvadams at usgs.gov
Cc: r-help at r-project.org
Subject: Re: [R] Construct a File Path: File Path Unknown
Jean, Thank you. It's slow but it works. dir("C:/", pattern="plotrix.pdf", full.names=T,
ignore.case=T, recursive=T) Does anyone have a faster way? If it helps using:
shell.exec("search-ms://query=plotrix.pdf") utilizes windows's search bar to find the file (this is
quick), however it opens a screen that finds the file rather than providing me with the search path.
For a look at what that looks like on a windows machine click here: http://windows.microsoft.com/en-
US/windows7/products/features/windows-search I'm thinking there's a way to use this method to extract
the path even faster than dir(). TylerTo: tyler_rinker at hotmail.com
CC: r-help at r-project.org
Subject: Re: [R] Construct a File Path: File Path Unknown
From: jvadams at usgs.gov
Date: Thu, 25 Aug 2011 13:19:37 -0500
Try the dir() function.
?dir
# for example
dir("c:/", pattern="foo.pdf",
full.names=T, ignore.case=T, recursive=T)
Jean
Tyler Rinker wrote on 08/25/2011 11:54:28 AM:
I am not a programmer and am self-taught so I may lack the
language to ask this appropriately (perhaps why an rseek search was
unfruitful).
Let's say I saved a file to my desktop called foo.pdf. Then
I want
R to return the file path of
foo.pdf (pretend I don't know the location(path) of foo.pdf).
Question: How would I get R to return the unknown file path for
foo.pdf.
I hypothesize that the find find.package() function code contains
the secret for doing this but am unable to parse out the snippet to
do so.
I attempted file.path("foo.pdf")
which R returns [1] "foo.pdf" #not what I want
===========================================
R version 2.14 beta
Windows 7
Reproducible code is not appropriate for this query
______________________________________________
R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
it would probably be faster if you can be as specific as possible... in the
help that has been provided, it is looking everywhere in c:/
you could narrow that down a bit and save it from looking too deep in your
system.
dir("C:\Documents and Settings\username\Desktop", pattern="foo.pdf",
full.names=T, ignore.case=T, recursive=T)
**I'm not 100% about this, but it seems logical to me
William Dunlap wrote:
Try using normalizePath("foo.pdf") after creating
the file. It should return an absolute path to
an existing file.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Tyler Rinker
Sent: Thursday, August 25, 2011 12:43 PM
To: jvadams at usgs.gov
Cc: r-help at r-project.org
Subject: Re: [R] Construct a File Path: File Path Unknown
Jean, Thank you. It's slow but it works. dir("C:/",
pattern="plotrix.pdf", full.names=T,
ignore.case=T, recursive=T) Does anyone have a faster way? If it helps
using:
shell.exec("search-ms://query=plotrix.pdf") utilizes windows's search
bar to find the file (this is
quick), however it opens a screen that finds the file rather than
providing me with the search path.
For a look at what that looks like on a windows machine click here:
http://windows.microsoft.com/en-
US/windows7/products/features/windows-search I'm thinking there's a way
to use this method to extract
the path even faster than dir(). TylerTo: tyler_rinker at hotmail.com
CC: r-help at r-project.org
Subject: Re: [R] Construct a File Path: File Path Unknown
From: jvadams at usgs.gov
Date: Thu, 25 Aug 2011 13:19:37 -0500
Try the dir() function.
?dir
# for example
dir("c:/", pattern="foo.pdf",
full.names=T, ignore.case=T, recursive=T)
Jean
Tyler Rinker wrote on 08/25/2011 11:54:28 AM:
I am not a programmer and am self-taught so I may lack the
language to ask this appropriately (perhaps why an rseek search was
unfruitful).
Let's say I saved a file to my desktop called foo.pdf. Then
I want
R to return the file path of
foo.pdf (pretend I don't know the location(path) of foo.pdf).
Question: How would I get R to return the unknown file path for
foo.pdf.
I hypothesize that the find find.package() function code contains
the secret for doing this but am unable to parse out the snippet to
do so.
I attempted file.path("foo.pdf")
which R returns [1] "foo.pdf" #not what I want
===========================================
R version 2.14 beta
Windows 7
Reproducible code is not appropriate for this query
______________________________________________
R-help at r-project.org mailing list
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org 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 r-project.org 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.
-- View this message in context: http://r.789695.n4.nabble.com/Construct-a-File-Path-File-Path-Unknown-tp3768821p3769392.html Sent from the R help mailing list archive at Nabble.com.
If you create a directory to work in for your project you could store that and use that later maindir<-getwd() #then even if you change directories for different parts of your project (but remain inside that folder) you could put maindir variable into the path of the dir command. The less directories you have to scan through, the faster your answer. dir(maindir, pattern="foo.pdf", full.names=T, ignore.case=T, recursive=T) -- View this message in context: http://r.789695.n4.nabble.com/Construct-a-File-Path-File-Path-Unknown-tp3768821p3769397.html Sent from the R help mailing list archive at Nabble.com.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110825/75700161/attachment.pl>