Last data update: 2014.03.03

R: Scale rows of a species-sites data set
y2pR Documentation

Scale rows of a species-sites data set

Description

The response matrix for mdm diversity analyses requires that species (columns of the data matrix) are scaled to proportions i.e. that they sum to one for each site (row of the data matrix). Two matrices are particularly useful; these correspond to alpha and gamma diversities. The former is particularly useful for mdm anovas that include the alpha model which is computationally expensive using the function mdm.

Usage

y2p(y, mean=FALSE)

Arguments

y

matrix or data frame of numeric values to be transformed

mean

if mean = TRUE then each row is replaced by the species means scaled to row sums of one

Value

A matrix of the same dimensions as the input matrix. Each row of the matrix will sum to one.

Examples

mydata <- matrix(0:8,nrow=3,ncol=3)
mydata
y2p(mydata)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MDM)
Loading required package: nnet
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MDM/y2p.Rd_%03d_medium.png", width=480, height=480)
> ### Name: y2p
> ### Title: Scale rows of a species-sites data set
> ### Aliases: y2p
> 
> ### ** Examples
> 
> mydata <- matrix(0:8,nrow=3,ncol=3)
> mydata
     [,1] [,2] [,3]
[1,]    0    3    6
[2,]    1    4    7
[3,]    2    5    8
> y2p(mydata)
           [,1]      [,2]      [,3]
[1,] 0.00000000 0.3333333 0.6666667
[2,] 0.08333333 0.3333333 0.5833333
[3,] 0.13333333 0.3333333 0.5333333
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>