<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>S4 objects are different to the  classical S3 object like data.frames, lists and other "basic" objects. One of their peculiarities is that they're accessed through "@" operator. In truth, user is not meant to access the slots directly - the developer should provide methods to access all the slots that she or he deems appropriate for user to access. No method could mean either it hasn't been implemented yet, or is not implemented by design (Thibaut will have more to say about this).</div><div><br></div><div>And now crux of the matter. <span style="font-size: 12pt;">Your first two examples work because lists can be accessed through various operators. This is often done via `lapply(X = x, FUN = "[[", "element_name")`. In your case, you can try creating an anonymous function that accesses the slot.</span></div><div><span style="font-size: 12pt;"><br></span></div><div><p style="margin: 0px;" data-mce-style="margin: 0px;">library(adegenet)<br>data(nancycats)<br>x <- list(nancycats)<br>lapply(x, FUN = function(x) x$tab)</p><p style="margin: 0px;" data-mce-style="margin: 0px;"><br></p><p style="margin: 0px;" data-mce-style="margin: 0px;"><br></p><p style="margin: 0px;" data-mce-style="margin: 0px;">Cheers,</p><p style="margin: 0px;" data-mce-style="margin: 0px;">Roman</p><p style="margin: 0px;" data-mce-style="margin: 0px;"><br></p><p style="margin: 0px;" data-mce-style="margin: 0px;"><br></p></div><div><br></div><div><span name="x"></span>----<br>In god we trust, all others bring data.<span name="x"></span><br></div><div><br></div><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Vikram Chhatre" <crypticlineage@gmail.com><br><b>To: </b>adegenet-forum@lists.r-forge.r-project.org<br><b>Sent: </b>Monday, March 30, 2015 4:25:16 AM<br><b>Subject: </b>[adegenet-forum] extracting genefreq $tab from an indexed list<br><div><br></div><div dir="ltr">I am working with hundreds of genpop objects indexed in a list.  Using lapply and makefreq functions, population gene frequencies were stored in individual objects (1 per data set).<div><br></div><div>Here is an example with just three objects:</div><div><div><br></div><div>>summary(mygenpop)</div><div>                  Length Class  Mode</div><div>data1.str 1      genpop S4  </div><div>data2.str 1      genpop S4  </div><div>data3.str 1      genpop S4  </div></div><div><br></div><div>>mygenfreq <- lapply(mygenpop, function(x) makefreq(x, truenames=TRUE))</div><div><br></div><div>>summary(mygenfreq)<br></div><div><div>                  Length Class  Mode</div><div>data1.str 3      -none- list</div><div>data2.str 3      -none- list</div><div>data3.str 3      -none- list</div></div><div><br></div><div>>summary(mygenfreq[[1]]$tab)</div><div><div>> str(mygenfreq[[1]])</div><div> $ tab : num [1:30, 1:1974] 0.6 0.5 0.325 0.675 0.6 0.5 0.5 0.375 0.55 0.475 ...<br></div><div> $ nobs: num [1:30, 1:1000] 40 40 40 40 40 40 40 40 40 40 ...</div><div><br></div></div><div>Next job is to work with the $tab matrix, but I am not sure how to access it from all objects in one command.</div><div><br></div><div>>mygenfreqT <- lapply(mygenfreq[[1:3]]$tab, function(x) t(x))</div><div><br></div><div>This throws an error.   The syntax seems to be wrong, but I am not sure how to fix this.  Thanks for any help.</div><div><br></div><div>Vikram</div><div><br></div><div><br></div></div><br>_______________________________________________<br>adegenet-forum mailing list<br>adegenet-forum@lists.r-forge.r-project.org<br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</div><div><br></div></div></body></html>