title: nested ifelse statements and the use of curly braces
body: <p>I got mangled up in how to use curly braces and how to correctly use the nested if else syntax in R studio.</p>
  <p>Can you spot my errors?</p>
  <p>So there is one main statement checking if a depreciation calculation should occur. And then if it should indeed occur there are 3 possible cases if if it should not occur there is only 1 case.</p>
  <pre><code>if (depreciation) {
    
    if (is.character(depreciation_percentage) &amp; grepl(&quot;automatic_calculation&quot;, depreciation_percentage)) {
      # call function
      
      source(&quot;calculate_depreciation_percentage_v1.R&quot;)
      
      temp_depreciation_percentage = calculate_depreciation_percentage_v1(end_of_life_value_perc_temp, theoretische_afschrijfperiode, restwaarde_bouw_perc,bouwwaarde_perc,perceelwaarde_perc,current_nr_of_years,groeivoet_waarde_perceel)
      
      
    } else is.numeric(depreciation_percentage) {  # so it is assumed the value is numeric
      print(&quot;error in automatic depreciation calculation call&quot;)
      
      
      browser()
      wearntear_vec = seq(from = 0, to=(depreciation_percentage*size(end_of_life_value_perc_temp,2))-depreciation_percentage , by=depreciation_percentage )
      
      
    } else  {
      #   # should be impossible to arrive here
      # print(&quot;error in automatic depreciation calculation call&quot;)
      #   browser()
      
      
    }
    
  } else if depreciation != 1 {
    # do something
    # wearntear_vec = reeks van nullekes
  } 
  </code></pre>