title: Compare strings with logical operator in R
body: <p>I'm getting an error trying to compare and set weekday string values as either a "weekend" or a "weekday" using R. Any suggestions on how to approach this problem in a better way would be great.</p>
  
  <pre><code>x &lt;- c("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
  
  setDay &lt;- function(day){
            if(day == "Sat" | "Sun"){
             return("Weekend")
            } else { 
              return("Weekday")
            }
          }
  
  sapply(x, setDay)
  </code></pre>
  
  <p>This is the error I get back in RStudio:</p>
  
  <pre><code>Error in day == "Sat" | "Sun" : 
    operations are possible only for numeric, logical or complex types
  </code></pre>