Skip to content
Prev 353676 / 398503 Next

cut variable within a loop

On Aug 16, 2015, at 8:57 AM, Janka VANSCHOENWINKEL wrote:

            
I now see that you did explain that you wanted the positional matching in cut2 as a "break". The code runs without error on my machine, but delivers a lot of warnings about masking. You are repeatedly using attach on the same named objects. Using `attach` in programming is generally not a good idea. In interactive use it is safer to use `with`, although that is not generally considered safe in programming, either.

You need to do a better job of nailing down the source of the difficulty what ever it might be. While you say the cut2 function "doesn't work", you don't actually give evidence of "failure".

It's fairly simple to show that your theory about why your code fails in some way as being due to cut2 failing to accept an "i" value inside an lapply call is just wrong:
[[1]]
 [1]  0      [ 1,10] [ 1,10] [ 1,10] [ 1,10] [ 1,10] [ 1,10]
 [8] [ 1,10] [ 1,10] [ 1,10] [ 1,10]
Levels:  0 [ 1,10]

[[2]]
 [1] [ 0, 2) [ 0, 2) [ 2,10] [ 2,10] [ 2,10] [ 2,10] [ 2,10]
 [8] [ 2,10] [ 2,10] [ 2,10] [ 2,10]
Levels: [ 0, 2) [ 2,10]

[[3]]
 [1] [ 0, 3) [ 0, 3) [ 0, 3) [ 3,10] [ 3,10] [ 3,10] [ 3,10]
 [8] [ 3,10] [ 3,10] [ 3,10] [ 3,10]
Levels: [ 0, 3) [ 3,10]


You also have two different definitions of weight2 for your irrigation model:

Alldata_Irrigation$weight2<-Alldata_Irrigation$sys02*Alldata_Irrigation$se025
Alldata_Irrigation$weight2<-Alldata_Irrigation$b48+Alldata_Irrigation$b50