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

ignore missing variable in R

$
0
0
> DS
 datum      AUL_T ZUL_T_SW 
1  25.06.2017     21.9      22   
2  25.06.2017     21.9      22   
3  25.06.2017     21.9      22   
4  25.06.2017     21.9      22   
5  25.06.2017     21.9      22   
6  25.06.2017     21.9      22   
7  25.06.2017     21.9      22 
[ reached 'max' / getOption("max.print") -- omitted 172822 rows ]

> ifelse(DS$AUL_T < 25 || DS$ZUL_T < 22, 1, 0)
[1] NA
> ifelse(DS$AUL_T < 25, 1, 0)
   [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  [37] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  [73] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [109] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  

Not every data set has the same data points, which is why the tests should be provided with various queries (OR). If a variable from the query does not exist, this should be ignored. In the given example DS$ZUL_T is not part of the data set and thus it should only test DS$AUL_T < 25. Nevertheless, I get no result instead of multiple 1. Do you know how I can deal with this problem in R?


Viewing all articles
Browse latest Browse all 206316

Trending Articles



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