What's wrong with my code?
Hi Susie, At a guess, there are no non-missing arguments to min or max. But no, we can't help you. You haven't provided a minimal reproducible example, and without knowing anything about your data it is impossible for the list to offer any constructive suggestions. The posting guide offers suggestions for doing that. In particular, dput() and str() are both very useful. Sarah
On Tue, Jul 12, 2011 at 11:15 AM, Susie <susiecrab_ling at hotmail.com> wrote:
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.
When I plugged in these codes, R produced only one plot for the file
"eight", and it states my error(see below) I have edited and checked my
codes so many times but still couldn't figure out what's wrong with
it...would you please help me? Thanks!
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=="Outgoing from panel hh" & 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
Sarah Goslee http://www.functionaldiversity.org