[adegenet-forum] Subsetting a genpop object for loc.nall

Zhian Kamvar zkamvar at gmail.com
Mon Apr 20 07:50:38 CEST 2015


That appears to be a bug. I have fixed it.

Zhian
> On Apr 19, 2015, at 19:30 , Vikram Chhatre <crypticlineage at gmail.com> wrote:
> 
> 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
> 
> 



More information about the adegenet-forum mailing list