Skip to contents

You can subset traits by identifier or by position using the `[` operator.

Usage

# S4 method for traits,missing,missing,missing
[(x, i, j, ..., drop = FALSE)

# S4 method for traits,numeric,missing,missing
[(x, i, j, ..., drop = FALSE)

# S4 method for traits,character,missing,missing
[(x, i, j, ..., drop = FALSE)

Arguments

x

A traits object.

i

Position of the identifier or the name of the identifier itself.

j

Not used.

...

Additional arguments not used here.

drop

Not used.

Value

A traits object.

Examples

# Subset a traits object by identifier
traits_ex01['EFO_0004884']
#> An object of class "traits"
#> Slot "traits":
#> # A tibble: 1 × 3
#>   efo_id      trait       uri                                 
#>   <chr>       <chr>       <chr>                               
#> 1 EFO_0004884 breast size http://www.ebi.ac.uk/efo/EFO_0004884
#> 

# Or by its position in table traits
traits_ex01[1]
#> An object of class "traits"
#> Slot "traits":
#> # A tibble: 1 × 3
#>   efo_id      trait       uri                                 
#>   <chr>       <chr>       <chr>                               
#> 1 EFO_0004884 breast size http://www.ebi.ac.uk/efo/EFO_0004884
#> 

# Keep all traits except the second
traits_ex01[-2]
#> An object of class "traits"
#> Slot "traits":
#> # A tibble: 2 × 3
#>   efo_id      trait            uri                                 
#>   <chr>       <chr>            <chr>                               
#> 1 EFO_0004884 breast size      http://www.ebi.ac.uk/efo/EFO_0004884
#> 2 EFO_0005299 non-word reading http://www.ebi.ac.uk/efo/EFO_0005299
#>