[adegenet-forum] trouble accessing @other

Thibaut Jombart thibautjombart at gmail.com
Thu Oct 25 13:33:45 CEST 2018


Hi there,

I think the NA in your logical vector may be the problem; can you try
wrapping a 'which' around it?

to_keep <- which(asocial.gl at other$basin=="Rhone_Valais")
asocial.gl[to_keep,]

Let us know if it works.
Best
Thibaut

--
Dr Thibaut Jombart
Associate Professor in Outbreak Analytics, London School of Hygiene and
Tropical Medicine
Senior Lecturer in Genetic Analysis, Imperial College London
President of RECON: repidemicsconsortium.org
https://thibautjombart.netlify.com
Twitter: @TeebzR


On Thu, 25 Oct 2018 at 00:43, Amaranta Fontcuberta <
amaranta.fontcuberta at unil.ch> wrote:

> Hello,
>
> 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.
> I stored 3 categorical variables in the @other slot. It looks like that:
> *> str(other(asocial.gl <http://asocial.gl>))*
> List of 3
>  $ basin : Factor w/ 3 levels "Rhine","Rhone_Valais",..: NA 2 NA 2 2 2 2 2
> 2 2 ...
>  $ Sgeno : Factor w/ 3 levels "mm","mp","pp": 1 2 3 1 1 1 1 1 1 1 ...
>  $ Spheno: Factor w/ 2 levels "M","P": 1 2 2 1 1 1 1 1 1 1 ...
>
> When I try to subset my dataset, I get this error:
> *> asocial.gl <http://asocial.gl>[asocial.gl at other$basin=="Rhone_Valais",]*
> Error in .local(x, i, j, ..., drop = drop) :
>   trying to get slot "n.loc" from an object of a basic class ("NULL") with
> no slots
>
> 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.
> *> asocial.gl at other$basin=="Rhone_Valais"*
>   [1]    NA FALSE    NA FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
>  TRUE  TRUE  TRUE
>  [15]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
>  TRUE  TRUE  TRUE
>  ...
>
> I use the same subseting command to select according to the @pop slot and
> it works well.
>
>
> Any help will be appreciated,
>
> Thanks a lot in advance,
>
> Amaranta.
> ----------------------------------------------------------
> Amaranta Fontcuberta, assistante diplômée
> Dept. Écologie et Évolution
> Université de Lausanne
>
> _______________________________________________
> adegenet-forum mailing list
> adegenet-forum at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20181025/e9b2eb30/attachment.html>


More information about the adegenet-forum mailing list