<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;"><br>
<div><font size="2">Hi there,<br>
<br>
the operator [[]] returns a slot of a list, not a list, which is an issue here. To subset a list you should use [].<br>
<br>
Otherwise, to do what you want, you need something like:<br>
lapply(mygenfreq, function(e) t(e$tab))<br>
<br>
Note that as of adegnet_2.0-0, there will be a simpler interface to get frequencies (tab(x, freq=TRUE)).<br>
<br>
Cheers<br>
Thibaut<br>
<br>
<br>
</font></div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF454351"><font size="2" color="#000000" face="Tahoma"><b>From:</b> adegenet-forum-bounces@lists.r-forge.r-project.org [adegenet-forum-bounces@lists.r-forge.r-project.org] on behalf of Vikram Chhatre [crypticlineage@gmail.com]<br>
<b>Sent:</b> 30 March 2015 03:25<br>
<b>To:</b> adegenet-forum@lists.r-forge.r-project.org<br>
<b>Subject:</b> [adegenet-forum] extracting genefreq $tab from an indexed list<br>
</font><br>
</div>
<div></div>
<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>
</div>
</div>
</div>
</body>
</html>