Retrieves or defines the row sums (before closure).
Usage
totals(object)
totals(object) <- value
# S4 method for class 'CompositionMatrix'
totals(object)
# S4 method for class 'LogRatio'
totals(object)
# S4 method for class 'CompositionMatrix'
totals(object) <- value
Value
totals() <- value
returns an object of the same sort asobject
with the new row sums assigned.totals()
returns the row sums ofobject
.
See also
Other mutators:
as.data.frame()
,
labels()
,
weights()
Examples
## Create a count matrix
A1 <- matrix(data = sample(1:100, 100, TRUE), nrow = 20)
## Coerce to compositions
B <- as_composition(A1)
## Row sums are internally stored before coercing to relative frequencies
totals(B)
#> [1] 264 346 145 310 256 201 270 334 349 250 349 259 234 207 129 272 278 187 282
#> [20] 172
## This allows to restore the source data
A2 <- as_amounts(B)
## Coerce to a data.frame
X <- as.data.frame(B)
head(X)
#> V1 V2 V3 V4 V5
#> S1 0.1856061 0.3295455 0.01893939 0.204545455 0.261363636
#> S2 0.1936416 0.2861272 0.26589595 0.190751445 0.063583815
#> S3 0.6000000 0.1517241 0.04137931 0.200000000 0.006896552
#> S4 0.2903226 0.1806452 0.20000000 0.238709677 0.090322581
#> S5 0.2226562 0.2539062 0.02343750 0.269531250 0.230468750
#> S6 0.2885572 0.2587065 0.08457711 0.009950249 0.358208955