title: Argument is of length zero
body: <p>I am trying to use the following syntax to get the occupation information from George Clooney's wikipedia page. Eventually I would like there to be a loop to get data on various personalitys' occupations.</p>
  
  <p>However, I get the following problem running the below code:</p>
  
  <blockquote>
  <pre><code>Error in if (symbol != "role") symbol = NULL : argument is of length zero
  </code></pre>
  </blockquote>
  
  <p>I am not sure why this keeps on coming up.</p>
  
  <pre><code>library(XML)
  library(plyr)
    url = 'http://en.wikipedia.org/wiki/George_Clooney'  
  
  # don't forget to parse the HTML, doh!
    doc = htmlParse(url)  
  
  # get every link in a table cell:
    links = getNodeSet(doc, '//table/tr/td') 
  
  # make a data.frame for each node with non-blank text, link, and 'title' attribute:
    df = ldply(links, function(x) {
                  text = xmlValue(x)
              if (text=='') text=NULL
           symbol = xmlGetAttr(x, 'class')
           if (symbol!='role') symbol=NULL
           if(!is.null(text) &amp; !is.null(symbol))
                   data.frame(symbol, text)         } )  
  </code></pre>