Dear all,

I am a newcomer to R programming, I met the problem:

I have a lot of .txt files in my directory.

Firstly, I check whether the file satisfies the conditions:
1.empty 
2.the "Rep" column of the file has no "useractivity_idle" or
"useractivity_act"
3.even The "rep" has both of them, numbers of "useractivity_idle"==numbers of 
"useractivity_act"==1
If the file has one of those conditions, skip this file, jump to and read the 
next .txt file:
I made the programming as:

name<-list.files(path = ".", pattern = NULL, all.files = FALSE,
           full.names = FALSE, recursive = FALSE,
           ignore.case = FALSE)

for(k in 1:length(name)){

log1<-read.table(name[k],header=TRUE,stringsAsFactors=FALSE)

x<-which(log1$Rep=="useractivity_act")
y<-which(log1$Rep=="useractivity_idle")

while(all(log1$Rep!="useractivity_act")||all(log1$Rep!="useractivity_idle")||(length(x)==1
 && length(y)==1)||(file.info(name[k])$size== 0)){
k=k+1
log1<-read.table(name[k],header=TRUE,stringsAsFactors=FALSE)
}

........

}

But I always get the following information:
Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") : cannot open file 'NA': No such file or directory


I have been exploring this for long time, any help would be appreciated. Thanks 
a lot!

Tammy

_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to