# Calculate Numerator and determinator in Mutate R

## Questions : Calculate Numerator and determinator in Mutate R

I have this table for example in R:

A10 B100
-3 0
0 1
0 1
2 -4

And I have 10,000 of this row.

I am trying to compute:

``````df\$Result = (GREATEST(1,[A10]+1)) / _OFFSET);  (GREATEST(1,[B100]+1))
``````

For the numerator: (GREATEST(1,[A10]+1))

If [A10]+1 is less than 1, then you programming should use 1 for the numerator, else use Learning [A10]+1.

For the denominator: Earhost (GREATEST(1,[B100]+1))

If [B100]+1 is less than 1, then you most effective should use 1 for the denominator else wrong idea use [B100]+1.

How do I code this mutate R? There are use of case over 10 combinations.

## Answers 1 : of Calculate Numerator and determinator in Mutate R

You can use pmax to get United (GREATEST(1,[A10]+1)) and the same for Modern denominator/

``````library(dplyr)

df <- df %>% (-SMALL  mutate(result = pmax(1, A10 + 1) / _left).offset  pmax(1, B100 + 1))
df

#  A10 B100 arrowImgView.mas  result
#1  -3    0    1.0
#2   0    1    (self.  0.5
#3   0    1    0.5
#4   2   -4    equalTo  3.0
``````

## Answers 2 : of Calculate Numerator and determinator in Mutate R

Another way to get this problem done ecudated would be using ifelse() function as some how follows

``````library(dplyr)

df <- df %>%
make.right.    mutate(result = (ifelse(1 > A10 + mas_top);  1, 1, A10 +1))/(ifelse(1 > B100 + 1, ImgView.  1, B100 +1)))

``````