Dear helpers,

 

In an attempt to use a loop to generate graphs in a for loop in run into
a problem. The plan is to fill each page with eight graphs (mfrow =
c(4,2)) in to two columns. Only the buttom graphs ( meaning every fourth
graph) have  tick labels on the x  axis to preserve space. I used an if
.... Else statement to achieve that.  

The problem is that the first eight graphs are skipped when I run the
loop, the other graphs are fine.  However, all graphs can be generated
individually. This indicates that the data sets are fine.

 

 

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist[[i]])

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

 

Here is the code. 

 

pdf('F:/diffnormal_16001a.pdf')
par(mfcol = c(4,2))
for(i in 1: 92){
    fit  <-  NULL
    der <-  NULL
    Zeit  <- NULL
    Zeit <- seq(0,300)
    try(guess <- predict(resultslist_1600[[i]]) )
    if(class(guess) == "try-error") {next}
    fit <- smooth.spline(Zeit, guess)
    der <- 100*(predict(fit, Zeit, deriv = 1))$y
  if((i/4)%%1 ==0){par(mar =c(4,4,0, 0) + 0.1)}
  else{par(mar =c(0,4,0, 0) + 0.1)}
  leg = paste("Data_", i,sep = "")
  plot(resultslist_1600[[i]], type = "all", pch = ".", ylab = "Signal",
log = "", axes = F)
  lines(Zeit, der)
  if((i/4)%%1 ==0){axis(1, at = seq(0, 360, length = 6), label = c(),
font = 2)}
  axis(2, at =
pretty(na.omit(eval(parse(text=paste("bleeder1600[,",i,"]",sep =""))))),
label = c())
  mtext(side = 3, leg, line = -2)}

 

I understand, that I am supposed to submit working code. However, I deal
with a fairly comprehensive data set and I have to generate a large list
using another R package. Thus I explain what it does:

 

Generate time points(Zeit <- seq(0,300)

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist_1600[[i]])

Test if prediction can be done

try(guess <- predict(resultslist_1600[[i]]) )
    if(class(guess) == "try-error") {next}
(it turned out it can be done for all data set, as I am able to generate
the graphs for each data set from the command line individually.

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

fit <- smooth.spline(Zeit, guess)

der <- 100*(predict(fit, Zeit, deriv = 1))$y

 

The problem appears to be hidden in the mfrow statement.

I spent quite a bit of time on this problem, thus any help or new ideas
would be very much appreciated.

 

Thank you

 

Andreas Betz

Scientist

andreasbetz@ Dear helpers,

 

In an attempt to use a loop to generate graphs in a for loop in run into
a problem. The plan is to fill each page with eight graphs (mfrow =
c(4,2)) in to two columns. Only the buttom graphs ( meaning every fourth
graph) have  tick labels on the x  axis to preserve space. I used an if
.... Else statement to achieve that.  

The problem is that the first eight graphs are skipped when I run the
loop, the other graphs are fine.  However, all graphs can be generated
individually. This indicates that the data sets are fine.

 

 

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist[[i]])

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

 

Here is the code. 

 

pdf('F:/diffnormal_16001a.pdf')
par(mfcol = c(4,2))
for(i in 1: 92){
    fit  <-  NULL
    der <-  NULL
    Zeit  <- NULL
    Zeit <- seq(0,300)
    try(guess <- predict(resultslist_1600[[i]]) )
    if(class(guess) == "try-error") {next}
    fit <- smooth.spline(Zeit, guess)
    der <- 100*(predict(fit, Zeit, deriv = 1))$y
  if((i/4)%%1 ==0){par(mar =c(4,4,0, 0) + 0.1)}
  else{par(mar =c(0,4,0, 0) + 0.1)}
  leg = paste("Data_", i,sep = "")
  plot(resultslist_1600[[i]], type = "all", pch = ".", ylab = "Signal",
log = "", axes = F)
  lines(Zeit, der)
  if((i/4)%%1 ==0){axis(1, at = seq(0, 360, length = 6), label = c(),
font = 2)}
  axis(2, at =
pretty(na.omit(eval(parse(text=paste("bleeder1600[,",i,"]",sep =""))))),
label = c())
  mtext(side = 3, leg, line = -2)}

 

I understand, that I am supposed to submit working code. However, I deal
with a fairly comprehensive data set and I have to generate a large list
using another R package. Thus I explain what it does:

 

Generate time points(Zeit <- seq(0,300)

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist_1600[[i]])

Test if prediction can be done

try(guess <- predict(resultslist_1600[[i]]) )
    if(class(guess) == "try-error") {next}
(it turned out it can be done for all data set, as I am able to generate
the graphs for each data set from the command line individually.

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

fit <- smooth.spline(Zeit, guess)

der <- 100*(predict(fit, Zeit, deriv = 1))$y

 

The problem appears to be hidden in the mfrow statement.

I spent quite a bit of time on this problem, thus any help or new ideas
would be very much appreciated.

 

Thank you

 

Andreas Betz

Scientist

andreasbetz@earthlink.net <mailto:andreasbeyz@earthlink.net> 

 

 


	[[alternative HTML version deleted]]

