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

Checking if value is greater in two columns and flagging

$
0
0

I am checking if Minvalue is less than or equal the threshold value , if it satisifies the condition then returns TRUE else False .

sample data

finaldf3:

MinValue|threshold

9.264539|10.30201 |

10.03875|10.24155 |

10.20306|10.24155 |

9.064350|10.24155 |

10.38772|10.24155 |

I am using ifelse to do this.

Code :

finaldf3$check<-ifelse(as.character(finaldf3$MinValue)<=as.character(finaldf3$threshold),'TRUE','FALSE')

Actual results :

MinValue|threshold|check

9.264539|10.30201 |FALSE

10.03875|10.24155 |TRUE

10.20306|10.24155 |TRUE

9.064350|10.24155 |FALSE

10.38772|10.24155 |FALSE

Expected results:

MinValue|threshold|check

9.264539|10.30201 |TRUE

10.03875|10.24155 |TRUE

10.20306|10.24155 |TRUE

9.064350|10.24155 |TRUE

10.38772|10.24155 |FALSE

Viewing all articles
Browse latest Browse all 201839

Trending Articles



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