I've written out codes for one particular file, and now I want to generate the same kind of graphs and files for the rest of similar data files.
For example, a file "8.csv" would look like such: enc_callee inout o_duration type A out 342 de B in 234 de C out 132 de E in 111 de A in 13 cf H in 15.7 cf G out 32 de A out 32 cf I in 14 de K in 189 de J out 34.1 cf B in 98.7 de H out 23 de C out 43 cf H in 567 cf I out 12 de E out 12 de K out 12 cf B in 1 cf A out 29 de D out 89 cf J in 302 de H in 12 cf A in 153 cf C out 233 de My command to deal with this simple file would be: eight <- read.csv(file="8.csv", header=TRUE, sep=",") eightout <- subset(eight, inout=="out" & o_duration>0, select=c(inout, enc_callee, o_duration)) f <- function(eightoutf) nrow(eightoutf) eightnocalls <- ddply(eightout,.(enc_callee),f) colnames(eightnocalls)[2] <- "nocalls" eightout$nocalls <- eightnocalls$nocalls [match(eightout$enc_callee, eightnocalls$enc_callee)] eightout=data.frame(eightout,"time"=c(1:nrow(eightout))) plot(eightout$time,eightout$nocalls) write.csv(eightout, "eightM.csv", row.names=FALSE) And then, R will produce "eightM.csv" as such: inout enc_callee o_duration nocalls time 1 out A 342.0 3 1 3 out C 132.0 3 2 7 out G 32.0 1 3 8 out A 32.0 3 4 11 out J 34.1 1 5 13 out H 23.0 1 6 14 out C 43.0 3 7 16 out I 12.0 1 8 17 out E 12.0 1 9 18 out K 12.0 1 10 20 out A 29.0 3 11 21 out D 89.0 1 12 25 out C 233.0 3 13 I will also get a plot http://r.789695.n4.nabble.com/file/n3662910/eightM.png What I want to do now, is that I have a few hundred similar files, and I want to generate the same type of plots and files, so I've written the following codes, however, R states that there's some error. I've tried editing many times but wasn't successful. my.files <- list.files() for (i in 1: length(my.files)) { temp.dat <- read.csv(my.files[i]) eight <- read.csv(file="8.csv", header=TRUE, sep=",") eightout <- subset(eight, inout=="out" & o_duration>0, select=c(inout, enc_callee, o_duration)) f <- function(eightoutf) nrow(eightoutf) eightnocalls <- ddply(eightout,.(enc_callee),f) colnames(eightnocalls)[2] <- "nocalls" eightout$nocalls <- eightnocalls$nocalls [match(eightout$enc_callee, eightnocalls$enc_callee)] eightout=data.frame(eightout,"time"=c(1:nrow(eightout))) plot(eightout$time,eightout$nocalls) write.csv(eightout, "eight.csv", row.names=FALSE) pdf(paste(Sys.Date(),"_",my.files[i],"_.pdf", sep="")) plot(temp.dat$time, temp.dat$nocalls, main=my.files[i]) dev.off() write.csv(temp.dat, paste(Sys.Date(),"_",my.files[i],"_.csv", sep=""), row.names=FALSE) } R says: need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf I wonder what went wrong with my codes, please help me! Thank you very much!! -- View this message in context: http://r.789695.n4.nabble.com/What-s-wrong-with-my-code-Edited-version-added-my-data-tp3662910p3662910.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.