<div dir="ltr"><div dir="ltr">Hi there, <div><br></div><div>I think the NA in your logical vector may be the problem; can you try wrapping a 'which' around it?</div><div><br></div><div>to_keep <- which(asocial.gl@other$basin=="Rhone_Valais")</div><div><a href="http://asocial.gl">asocial.gl</a>[to_keep,]</div><div><br></div><div>Let us know if it works.</div><div>Best</div><div>Thibaut<br clear="all"><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br><font face="arial, helvetica, sans-serif">--<br>Dr Thibaut Jombart<br>Associate Professor in Outbreak Analytics, London School of Hygiene and Tropical Medicine<br>Senior Lecturer in Genetic Analysis, Imperial College London</font></div><div><font face="arial, helvetica, sans-serif">President of RECON: <a href="http://repidemicsconsortium.org" target="_blank">repidemicsconsortium.org</a></font></div><div><font face="arial, helvetica, sans-serif"><a href="https://thibautjombart.netlify.com" style="letter-spacing:0.2px" target="_blank">https://thibautjombart.netlify.com</a><br></font></div><div><font face="arial, helvetica, sans-serif">Twitter: @TeebzR</font><br></div></div></div></div></div></div></div></div></div></div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, 25 Oct 2018 at 00:43, Amaranta Fontcuberta <<a href="mailto:amaranta.fontcuberta@unil.ch">amaranta.fontcuberta@unil.ch</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hello, </div><div><br></div><div>I want to subset part of the individuals of my genlight object according to a variable stored in the @other slot. I get an error I don't understand.</div><div>I stored 3 categorical variables in the @other slot. It looks like that: </div><div><div><b>> str(other(<a href="http://asocial.gl" target="_blank">asocial.gl</a>))</b></div><div>List of 3</div><div> $ basin : Factor w/ 3 levels "Rhine","Rhone_Valais",..: NA 2 NA 2 2 2 2 2 2 2 ...</div><div> $ Sgeno : Factor w/ 3 levels "mm","mp","pp": 1 2 3 1 1 1 1 1 1 1 ...</div><div> $ Spheno: Factor w/ 2 levels "M","P": 1 2 2 1 1 1 1 1 1 1 ...</div></div><div><br></div><div>When I try to subset my dataset, I get this error:</div><div><div><b>> <a href="http://asocial.gl" target="_blank">asocial.gl</a>[asocial.gl@other$basin=="Rhone_Valais",]</b></div><div>Error in .local(x, i, j, ..., drop = drop) : </div><div> trying to get slot "n.loc" from an object of a basic class ("NULL") with no slots</div></div><div><br></div><div>The condition seems to work well, since when I call it alone, it outputs a list of TRUE, FALSE that corresponds well to the individuals I want to keep. </div><div><div><b>> asocial.gl@other$basin=="Rhone_Valais"</b></div><div> [1] NA FALSE NA FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE</div><div> [15] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE</div><div> ...</div></div><div><br></div><div>I use the same subseting command to select according to the @pop slot and it works well. </div><br></div><div dir="ltr"><br></div><div dir="ltr">Any help will be appreciated, </div><div dir="ltr"><br></div><div dir="ltr">Thanks a lot in advance, </div><div dir="ltr"><br></div><div dir="ltr">Amaranta.<br clear="all"><div><div dir="ltr" class="m_3237634030841661282gmail_signature"><div dir="ltr"><div>----------------------------------------------------------</div>Amaranta Fontcuberta, assistante diplômée<div>Dept. Écologie et Évolution</div><div>Université de Lausanne</div></div></div></div><div dir="ltr"><br></div></div></div></div></div>
_______________________________________________<br>
adegenet-forum mailing list<br>
<a href="mailto:adegenet-forum@lists.r-forge.r-project.org" target="_blank">adegenet-forum@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a></blockquote></div>