Hi friends, Please help me with this bug. *Bug in my code:*
In this variable sub_grp_whr_cls_data[sbgrp_no,1] I store the where clause.every sub group has a where condition linked with it. Database1 Where clause was not found for a particular subgroup, sub_grp_whr_cls_data[sbgrp_no,1] value was NULL So the condition (*sub_grp_whr_cls_data[sbgrp_no,1]=="NULL" || sub_grp_whr_cls_data[sbgrp_no,1]==""*) should evaluate to TRUE ,but it evaluated to NA So the if block where I used the the condition threw error If(*sub_grp_whr_cls_data[sbgrp_no,1]=="NULL" || sub_grp_whr_cls_data[sbgrp_no,1]==""*) i.e if(NA) Error:-- Error in if (sub_grp_whr_cls_data[sbgrp_no, 1] == "NULL" || sub_grp_whr_cls_data[sbgrp_no, : missing value where TRUE/FALSE needed Comments:-- but when there s no where clause value the condition (sub_grp_whr_cls_data[sbgrp_no,1]=="NULL" ||sub_grp_whr_cls_data[sbgrp_no,1]=="") should automatically evaluate to * TRUE* Database2 Where clause was found for a particular subgroup The condition (sub_grp_whr_cls_data[sbgrp_no,1]=="NULL" ||sub_grp_whr_cls_data[sbgrp_no,1]=="") evaluated to FALSE So if (sub_grp_whr_cls_data[sbgrp_no,1]=="NULL" ||sub_grp_whr_cls_data[sbgrp_no,1]=="") is If (FALSE) ,control goes to the else part. This is exactly what is expected of the program. *QUERY:-- **If the condition evaluates to FALSE when a where condition is available why doesnt it evaluate to TRUE when a where condition available is NULL or no where condition is available.* Here I have taken the example of two databases where I tried to get the where clause for subgroup 1.In case of Database1 it was not available in case of Databse2 it was available.But the problem may appear for the same database also, when where clause is available for say one subgroup and not for the other. -- Thanks Moumita [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.