@shashwat.2014 wrote:
I was working on a data set while I noticed an issue with the usage of the AND operator in R.
The aim was to determine the indices of the rows which had year=2011, month=1 and day=20.
The following code gave an incorrect output 'integer(0)'
which((total$year==2011)&&(total$month==1)&&(total$day==20))
integer(0)However the following code worked quite fine.
which((total$year==2011)&(total$month==1)&(total$day==20))
[1] 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900
[15] 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910Could anyone please elaborate on its reason? Any answers would be highly appreciated.
Posts: 3
Participants: 2