R/addPrel.R

"addPrel" <-
function (model) 
{
	## prel has structure 
	## list(list(what1, ind1, 
	##           what2, ind2, 
	##           rel, start), ...) 
	
  prelspec <- model@prelspec
  model@prel <- vector()
  for(diffs in prelspec){
    model@prel <- append(model@prel, diffs$start)  
  }
  for(diffs in prelspec){
    #[email protected]el <- append([email protected], diffs$start)  
    if(length(diffs$rel) == 0 || diffs$rel == "lin"){
      newpar <- multiLin(model, diffs, diffs$start[1]) + diffs$start[2]
      if(length(diffs$ind1)==1)
        slot(model, diffs$what1)[diffs$ind1] <- newpar 
      if(length(diffs$ind1)==2) 
        slot(model, diffs$what1)[[diffs$ind1[1]]][diffs$ind1[2]] <- newpar      
    }
    else {
      if(diffs$rel == "multilin"){
        newpar <- diffs$start[[1]] + multiLin(model, diffs, diffs$start[2:length(diffs$start)]) # was diffs$start[1]
        if(length(diffs$ind1)==1)
          slot(model, diffs$what1)[diffs$ind1] <- newpar 
        if(length(diffs$ind1)==2) 
                slot(model, diffs$what1)[[diffs$ind1[1]]][diffs$ind1[2]] <- newpar 
      }
    }
  }
  model
}

Try the TIMP package in your browser

Any scripts or data that you put into this service are public.

TIMP documentation built on May 29, 2017, 1:21 p.m.