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

Zhian Kamvar zkamvar at gmail.com
Sun Apr 19 18:53:00 CEST 2015


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