title: R take maximum of cell and 0 for each element in column
body: <p>I am writing an objective function for a (non-linear) optimization problem in R. </p>
  
  <p>Input: two columns A and B, of length N
  Lets say that A_n is the n'th cel of column A, n
  
  <p>I do not want to use a loop as I want to code it as one function. 
  I already tried:
  max(A<em>B,0)
  apply(A</em>B,max)
  Both result each cell C_n having the maximum value of the column A<em>B, this makes sense to me. However, I just want to compare the outcome of each cell in A</em>B with zero and replace negative values by zero. How can I do that without using a loop or multiple steps?</p>