I need to use a loop and each time go to folder i and check availability of .RData file. If it exist load it and if not submit a command in linux. Something like this
for (i in 1:10){
setwd(~/i/)
if .Rdata (?????)
load (.RData
else
<run a command in linux like " cd ~/i/ ; qsub job$i.pbs" >
}
Any idea how to do that in R?
Farhad
check availability of a file in R
3 messages · Farhad Shokoohi, David Winsemius, Samuel Le
On Sep 6, 2011, at 8:07 PM, Farhad Shokoohi wrote:
I need to use a loop and each time go to folder i and check
availability of .RData file. If it exist load it and if not submit a
command in linux. Something like this
for (i in 1:10){
setwd(~/i/)
# Perhaps:
if (target %in% list.files( patt="\.Rdata") ) {
.Rdata (?????)
#load (.RData
load( target)
else
# perhaps you could explain your goals for this next operation?
<run a command in linux like " cd ~/i/ ; qsub job$i.pbs" > } Any idea how to do that in R? Farhad
David Winsemius, MD Heritage Laboratories West Hartford, CT
Does file.exists answer to your question?
file.exists(".RData")
If you are not sure of the exact name of the file but know it contains ".RData", you can try:
List.files(directory,".RData")
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Farhad Shokoohi
Sent: 07 September 2011 01:07
To: R-help at r-project.org
Subject: [R] check availability of a file in R
I need to use a loop and each time go to folder i and check availability of .RData file. If it exist load it and if not submit a command in linux. Something like this
for (i in 1:10){
setwd(~/i/)
if .Rdata (?????)
load (.RData
else
<run a command in linux like " cd ~/i/ ; qsub job$i.pbs" >
}
Any idea how to do that in R?
Farhad
______________________________________________
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.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 6275 (20110707) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
__________ Information from ESET NOD32 Antivirus, version of virus signature database 6275 (20110707) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com