title: Calculate z-score from another dataframe when meeting conditions in R
body: <p>I have two dataframes:</p>
  <pre><code>Node1&lt;-c(1, 2, 3, 4, 5, 6, 7)
  Node1&lt;-c(1, 1, 1, 2, 2, 3)
  Node2&lt;-c(2, 3, 4, 3, 4, 4)
  Mean&lt;-c(2, 1, 5, 3, 2, 3)
  SD&lt;-c(0.1, 0.2, 0.01, 0.2, 0.01, 0.01)
  df1&lt;-data.frame(Node1, Node2, Mean, SD)
  df1
    Node1 Node2 Mean   SD
  1     1     2    2 0.10
  2     1     3    1 0.20
  3     1     4    5 0.01
  4     2     3    3 0.20
  5     2     4    2 0.01
  6     3     4    3 0.01
  
  df2&lt;-data.frame(Node1, Node2, value)
  df2
    Node1 Node2 value
  1     1     2     1
  2     1     3     2
  3     1     4     1
  4     2     3     4
  5     2     4     6
  6     3     4     7
  </code></pre>
  <p>For each &quot;value&quot; row in df2, I want to calculate the z-score using the Mean and standard deviation (SD) from the corresponding Node pair (i.e., Node1 and Node2) from df1 as the reference values. E.g., for the first row from df2, the z-score should be ((1-2)/0.10) as the corresponding mean and SD are derived by matching Node1 and Node2 values from both dfs.</p>
  <p>How do I perform this in R? My current solutions are using <code>left_join</code> to combine df1 and df2, then use <code>mutate</code> and <code>case_when</code> but I'm unable to go beyond this to extract the z-scores while retaining specific conditions (i.e., do while matching Node1 and Node2 values from both dfs)</p>