Re: [R] treating integer(0) and NULL in conditions and loops

2016-03-11 Thread William Dunlap via R-help
I would suggesting using "" instead of NULL for rz, throughout this code. (I would also suggest making sure the code can be copied into R without causing a syntax error before posting the request for help.) Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Mar 11, 2016 at 9:10 AM, Adams, Jean

Re: [R] treating integer(0) and NULL in conditions and loops

2016-03-11 Thread Adams, Jean
To reframe the problem ... the issue is not with the function nchar() (or whatever), it's with the input value rz being null. I suggest you build into the loop whatever actions/outputs you want when rz is NULL. for (i in 1:10){ if (is.null(rz)) { # do something here } else { if (nchar

[R] treating integer(0) and NULL in conditions and loops

2016-03-11 Thread Jan Kacaba
Hello, I have following problem in loops. It occurred to me multiple times bellow is an example. Inside if() I have sometimes function f(x) which may return integer(0). If I test f(x)>1 and f(x)=integer(0) I get error. Maybe it can be solved more eloquently without loop or swithces. I don't know.