bind.loci: Bind Loci Objects

Description Usage Arguments Details Value Author(s) See Also Examples

Description

These functions combine objects of class "loci" by binding their rows or their columns.

Usage

1
2
3
4
## S3 method for class 'loci'
rbind(...)
## S3 method for class 'loci'
cbind(...)

Arguments

...

some object(s) of class "loci", separated with commas.

Details

These two methods call [rc]bind.data.frame and take care to respect the attribute “locicol” of the returned object.

You can pass a data frame in the ..., but then you should bypass the generic by calling cbind.loci directly. Do not try to pass a vector: this will mess the “locicol” attribute. Instead, make a data frame with this vector (see examples).

Value

An object of class "loci".

Author(s)

Emmanuel Paradis

See Also

[.loci

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
a <- as.loci(data.frame(x = "A/a", y = 1), col.loci = 1)
b <- as.loci(data.frame(y = 2, x = "A/A"), col.loci = 2)
## rbind.loci reorders the columns if necessary:
str(rbind(a, b))
## cbind sets "locicol" correctly:
str(cbind(a, b))
str(cbind(b, a))
## Unexpected result...
str(cbind(a, data.frame(z = 10)))
## ... bypass the generic:
str(pegas:::cbind.loci(a, data.frame(z = 10)))
## ... or much better: a$z <- 10
## Here "locicol" is not correct...
str(pegas:::cbind.loci(z = 10, a))
## ... instead
str(pegas:::cbind.loci(data.frame(z = 10), a))

Example output

Loading required package: ape
Loading required package: adegenet
Loading required package: ade4

   /// adegenet 2.0.1 is loaded ////////////

   > overview: '?adegenet'
   > tutorials/doc/questions: 'adegenetWeb()' 
   > bug reports/feature requests: adegenetIssues()



Attaching package: 'pegas'

The following object is masked from 'package:ade4':

    amova

The following object is masked from 'package:ape':

    mst

Classes 'loci' and 'data.frame':	2 obs. of  2 variables:
 $ x: Factor w/ 2 levels "A/a","A/A": 1 2
 $ y: num  1 2
 - attr(*, "locicol")= num 1
Classes 'loci' and 'data.frame':	1 obs. of  4 variables:
 $ x: Factor w/ 1 level "A/a": 1
 $ y: num 1
 $ y: num 2
 $ x: Factor w/ 1 level "A/A": 1
 - attr(*, "locicol")= num  1 4
Classes 'loci' and 'data.frame':	1 obs. of  4 variables:
 $ y: num 2
 $ x: Factor w/ 1 level "A/A": 1
 $ x: Factor w/ 1 level "A/a": 1
 $ y: num 1
 - attr(*, "locicol")= num  2 3
List of 4
 $ : Factor w/ 1 level "A/a": 1
 $ : num 1
 $ : num 10
 $ : num 10
 - attr(*, "dim")= int [1:2] 2 2
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:2] "x" "y"
  ..$ : chr [1:2] "a" ""
Classes 'loci' and 'data.frame':	1 obs. of  3 variables:
 $ x: Factor w/ 1 level "A/a": 1
 $ y: num 1
 $ z: num 10
 - attr(*, "locicol")= num 1
Classes 'loci' and 'data.frame':	1 obs. of  3 variables:
 $ x[[1]]: num 10
 $ x     : Factor w/ 1 level "A/a": 1
 $ y     : num 1
 - attr(*, "locicol")= Named num 3
  ..- attr(*, "names")= chr ""
Classes 'loci' and 'data.frame':	1 obs. of  3 variables:
 $ z: num 10
 $ x: Factor w/ 1 level "A/a": 1
 $ y: num 1
 - attr(*, "locicol")= num 2

pegas documentation built on May 17, 2021, 9:08 a.m.