Description Usage Arguments Value Author(s) References Examples
'AitTrans' calculates log-ratio transformed measurements to account for individual size-effects.
1 |
data |
a dataframe with as many rows as individuals. The first column contains the name of the population to which the individual belongs, the others contain quantitative variables. |
Rp |
a vector containing the names of the populations to be deleted. |
Ri |
a vector containing each number of individual to be deleted. The vector Ri must contain existent individuals, each of them once. |
the data frame with transformed variables.
Blondeau Da Silva Stephane - Da Silva Anne.
Aitchison J., 1986. The Statistical Analysis of Compositional Data. Chapman and Hall, London - New York, XII, 416 pp.
Peres-Neto P.R., Magnan P., 2004. The influence of swimming demand on phenotypic plasticity and morphological integration: a comparison of two polymorphic charr species. Oecologia 140, 36-45.
Shinn C. et al., 2015. Phenotypic variation as an indicator of pesticide stress in gudgeon: accounting for confounding factors in the wild. Science of the Total Environment 538, 733-742.
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 40 41 42 43 44 45 | data(test)
AitTrans(test)
## The function is currently defined as
function (data, Rp = 0, Ri = 0)
{
nb.var = dim(data)[2] - 1
dat.rem.ind.pop <- function(data, ind = 0, pop = 0) {
data = as.data.frame(data)
dat.rem.ind <- function(dat, ind) {
nb.rem.ind = length(ind)
nb.ind = dim(dat)[1]
for (i in 1:nb.rem.ind) dat = dat[row.names(dat)[1:(nb.ind -
i + 1)] != ind[i], ]
return(dat)
}
dat.rem.pop <- function(dat, pop) {
nb.rem.pop = length(pop)
for (i in 1:nb.rem.pop) dat = dat[dat[, 1] != pop[i],
]
return(dat)
}
if (ind[1] != 0)
data = dat.rem.ind(data, ind)
if (pop[1] != 0)
data = dat.rem.pop(data, pop)
return(data)
}
nonNa.row <- function(data, row) {
nb.na = 0
for (i in 1:nb.var) if (is.na(data[row, i + 1]))
nb.na = nb.na + 1
return(nb.var - nb.na)
}
data = dat.rem.ind.pop(data, ind = Ri, pop = Rp)
nb.ind = dim(data)[1]
cor.val = rep(0, nb.ind)
for (i in 1:nb.ind) {
cor.val[i] = 1/(nonNa.row(data, i)) * sum(log(data[i,
-1], base = 10), na.rm = TRUE)
for (j in 1:nb.var) data[i, (j + 1)] = log(data[i, (j +
1)], base = 10) - cor.val[i]
}
return(data)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.