title: R: Error!! : object of type 'S4' is not subsettable
body: <p>I am working with "<em>rehh</em>" package of R.</p>
  
  <p>I create an object chr21 of class haplohh from data2haplohh function of the package.</p>
  
  <p>Now when I try to write it to a file:</p>
  
  <pre><code> write.table(chr21, file = "CHR21", append = FALSE, quote = TRUE,sep = "\t", eol="\n", na= "NA", dec=".", row.names=TRUE, col.names=TRUE)
  </code></pre>
  
  <p>The error I get is: </p>
  
  <blockquote>
    <p>Error in as.data.frame.default(x[[i]], optional = TRUE) :
      cannot coerce class "structure("haplohh", package = "rehh")" to a data.frame</p>
  </blockquote>
  
  <p>Also when I try to print first 10 rows of chr21,</p>
  
  <pre><code>head(chr21, n=10)
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Error in x[seq_len(n)] : object of type 'S4' is not subsettable</p>
  </blockquote>
  
  <p>OK so am adding the output of <em>str(chr21)</em>:</p>
  
  <blockquote>
    <p>str(chr21)</p>
    
    <p>Formal class 'haplohh' [package "rehh"] with 6 slots</p>
    
    <p>..@ haplo   : num [1:10, 1:1010554] 0 2 2 2 0 2 0 2 0 2 ... </p>
    
    <p>..@ position: num [1:1010554] 9411410 9411645 9411785 9412503 9413228 ...</p>
    
    <p>..@ snp.name: chr [1:1010554] "rs78200054" "rs71235074" "rs71235075" "rs71220884" ...</p>
    
    <p>..@ chr.name: chr "21"</p>
    
    <p>..@ nhap    : int 10</p>
    
    <p>..@ nsnp    : int 1010554</p>
  </blockquote>
  
  <p>I am a newbie in R, It would be really great If I could get to know where I am going wrong and how to fix this error.</p>
  
  <p>Thanks in advance!</p>