Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

logical operators and, or are not working

$
0
0

The R condition is not working properly.

I am using logical operators && and || but both are not working.

df = data.frame(c("enrty 1","enrty 2","enrty 3") ,c(12200, 1, 120), c(111111, 12, 123), c(1, 1, 0 ) , c(0,1,0), c(1,0,1))

names(df) = c('Name', 'X1', 'X2', 'X3','X4','X5')

if (((df$X3 > 1) || (df$X1  < 1000)) &&  ((df$X4 > 1) || (df$X2 < 1000))){
  df$condition1 = 1
} else {
  df$condition1 = 0
}

if ((df$X3 > 1) || (df$X1  < 1000)) {  
  df$condition2 = 1
} else {
  df$condition2 = 0
}

if ((df$X4 > 1) || (df$X2 < 1000)) {  
  df$condition3 = 1
} else {
  df$condition3 = 0
}

Output: https://drive.google.com/file/d/1P6VrT-xePBXNaYUi2fdKTJyuhThc4jcf/view?usp=sharing


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>