samp: Accessing and Replacing Parts of 'Mefa' Objects

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

Description

Methods to access and replace parts (elements, slots) of "Mefa" objects.

Usage

1
2
3
4
5
6
7
8
xtab(x)
"xtab<-"(x, value)

samp(x)
"samp<-"(x, value)

taxa(x)
"taxa<-"(x, value)

Arguments

x

an object of S4 class "Mefa".

value

replacement value.

Details

The [ method ensures that the xtab sparse matrix part and the corresponding attribute tables are subsetted correctly.

Validity check is performed when replacing slots of an object.

Value

An object of S4 class "Mefa".

Author(s)

Peter Solymos <solymos@ualberta.ca>

See Also

Mefa

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
x <- data.frame(
    sample = paste("Sample", c(1,1,2,2,3,4), sep="."),
    species = c(paste("Species", c(1,1,1,2,3), sep="."),  "zero.pseudo"),
    count = c(1,2,10,3,4,0),
    stringsAsFactors = TRUE)
samp <- data.frame(samples=levels(x$sample), var1=1:2,
    stringsAsFactors = TRUE)
taxa <- data.frame(specnames=levels(x$species), var2=c("b","a"),
    stringsAsFactors = TRUE)
rownames(samp) <- samp$samples
rownames(taxa) <- taxa$specnames
x1 <- Xtab(count ~ sample + species, x)
x3 <- Mefa(x1, samp, taxa)

## accessing the xtab slot
xtab(x3)
## replacing the slot value
x1[3,1] <- 999
xtab(x3) <- x1
xtab(x3)

## accessing and replacing the samp slot
samp(x3)
samp(x3) <- NULL
samp(x3)
samp(x3) <- samp[1:3,]
samp(x3)

## accessing and replacing the taxa slot
taxa(x3)
taxa(x3) <- NULL
taxa(x3)
taxa(x3) <- taxa[1:3,]
taxa(x3)

## subsetting
unclass(x3[3:2, 1:2])
unclass(x3[3:2,])
unclass(x3[,1:2])

mefa4 documentation built on Oct. 7, 2021, 1:06 a.m.