title: How to capitalise the first character of a value for selected values in a column of a data frame in R?
body: <p>I have a data frame column with values such as "DSL" , "Fiber optic" , "No", NA, "fiber optic".I want to capitalise the first character of the value 'fiber optics 'so it looks like 'Fiber optics' and i want to leave the rest of the values as it is i.e 'DSL','No' and NA should remain unchanged. I used the below code.However I get an error in the if condition I used</p>
  
  <p>Whats wrong with the below code.</p>
  
  <pre><code>fix_cases_condition &lt;- function(x){
    if (x!='DSL' | x!='No' | !is.na(x) ){
      first = toupper(substr(x,start = 1,stop = 1))
      rest = tolower(substr(x,start = 2,stop = nchar(x)))
      paste0(first,rest)
    }
  }
  internet$`Internet Service` &lt;- sapply(internet$`Internet Service`,fix_cases_condition)
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>Error in if (x != "DSL" | x != "No" | !is.na(x)) { : 
    missing value where TRUE/FALSE needed
  </code></pre>