[adegenet-forum] Subsetting a genpop object for loc.nall
Vikram Chhatre
crypticlineage at gmail.com
Mon Apr 20 04:30:04 CEST 2015
Hi Zhian,
What is the second line of code supposed to do? It seems to fail:
> myloc <- locNames(mygenpop)[mygenpop at loc.nall == 2]
> mygenpop[loc=myloc]
Error in tab[i, j, ..., drop = FALSE] :
(subscript) logical subscript too long
On Sun, Apr 19, 2015 at 12:53 PM, Zhian Kamvar <zkamvar at gmail.com> wrote:
> Hi.
>
> The function subset is a wrapper for the square brackets that acts on the
> rows of a data frame or matrix.
>
> Since you want the loci (columns), you will need to use the loc argument:
>
> in adegenet 2.0:
>
> myloc <- locNames(mygenpop)[mygenpop at loc.nall == 2]
> mygenpop[loc = myloc]
>
> in adegenet 1.4:
>
> myloc <- names(locNames(mygenpop)[mygenpop at loc.nall == 2])
> mygenpop[loc = myloc]
>
> Zhian
> > On Apr 19, 2015, at 03:00 ,
> adegenet-forum-request at lists.r-forge.r-project.org wrote:
> >
> > I was hoping to subset the genpop object conditional upon number of
> > alleles, but it doesn't seem to work. Are there any workarounds?
> >
> >> mygenpop_sub <- subset(mygenpop, mygenpop at loc.nall == 2)
> > Error in tab[i, j, ..., drop = FALSE] :
> > (subscript) logical subscript too long
> >
> > Thanks
> > V
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150419/15b56f50/attachment.html>
More information about the adegenet-forum
mailing list