title: Test if variable is empty in R
body: <p>I have a situation where I need to test whether a variable is <code>factor(0)</code> but any logical test (including comparing to NULL) I try to assign to it gives <code>logical(0)</code>. How do I test if something is an empty factor?</p>
  
  <p>edit: allow me to elaborate.</p>
  
  <p>I have a function and it looks at the attribute of the vector that it takes in, but not every vector has that the attribute, so for vectors that don't have the attribute, when I query the attribute <code>attr(vector,"attribute")</code> my return is factor(0) but when I compare that to 0 I get <code>logical(0)</code> and comparing it to null or NA also won't work. Any ideas?</p>