title: Package check and logic; is.element
body: <p>This may be another repeat of this issue but here we go. </p>
  
  <p>I'm building a .Rprofile package checker. I also use a similar script for r scripts I send to my coworkers who are not technical. It checks for packages and installs them if they are not there and loads them if they are. I found a bunch of resources on package checking but for some reason as soon as you start sticking these checks into functions or the .Rprofile things get strange. </p>
  
  <p>if someone could tell me what is wrong with this function it would be a huge help. I am really scratching my head on this.</p>
  
  <pre><code>startup_packagecheck&lt;-function(pkg){
    library("utils")
    if(!is.element(pkg, installed.packages()))
      return(TRUE)
  }
  startup_packagecheck(pkg=MASS)
  </code></pre>