[Esm-commits] r8 - in pkg/ESM: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 12 10:44:40 CET 2009


Author: timotheepoisot
Date: 2009-11-12 10:44:40 +0100 (Thu, 12 Nov 2009)
New Revision: 8

Added:
   pkg/ESM/R/GDS.r
   pkg/ESM/R/draw.network.r
   pkg/ESM/R/matrix.hr.r
   pkg/ESM/R/sortmat.byspe.r
   pkg/ESM/R/std.matrix.r
Modified:
   pkg/ESM/DESCRIPTION
   pkg/ESM/R/functions.r
Log:
Each function other than specificity measure is now a separated file

Modified: pkg/ESM/DESCRIPTION
===================================================================
--- pkg/ESM/DESCRIPTION	2009-11-11 22:21:02 UTC (rev 7)
+++ pkg/ESM/DESCRIPTION	2009-11-12 09:44:40 UTC (rev 8)
@@ -1,5 +1,5 @@
 Package: ESM
-Version: 0.1.1-01
+Version: 0.1.1-02
 Date: 2009-11-06
 Title: Ecological Specificity Measures
 Author: Timothee Poisot <timothee.poisot at univ-montp2.fr>, Michael E Hochberg <michael.hochberg at univ-montp2.fr>

Added: pkg/ESM/R/GDS.r
===================================================================
--- pkg/ESM/R/GDS.r	                        (rev 0)
+++ pkg/ESM/R/GDS.r	2009-11-12 09:44:40 UTC (rev 8)
@@ -0,0 +1,12 @@
+GDS <- function(mat)
+{
+	D <- dim(mat)
+	N <- prod(D)
+	Ni <- sum(mat>0)/N
+	out <- NULL
+	out$RES <- D[1]
+	out$ORGA <- D[2]
+	out$SIZE <- N
+	out$COMP <- Ni
+	return(out)
+}
\ No newline at end of file

Added: pkg/ESM/R/draw.network.r
===================================================================
--- pkg/ESM/R/draw.network.r	                        (rev 0)
+++ pkg/ESM/R/draw.network.r	2009-11-12 09:44:40 UTC (rev 8)
@@ -0,0 +1,57 @@
+draw.network <- function(data,org.col='grey',res.col='grey',border=NA,sortorg=c(1:nrow(data)),sortres=c(1:ncol(data)),...)
+{
+	
+	data <- sortmat.byspe(data,sortorg)
+	data <- t(sortmat.byspe(t(data),sortres))
+	
+	n.elements <- max(dim(data))
+	
+	pos.h <- seq(from=1,to=n.elements,length.out=ncol(data))
+	pos.p <- seq(from=1,to=n.elements,length.out=nrow(data))
+	
+	par(bty='n',xaxt='n',yaxt='n')
+	symbols(
+		pos.p,
+		y = rep(2,length(pos.p)),
+		circles=rep(0.3,length(pos.p)),
+		inches=FALSE,
+		add=FALSE,
+		ylim=c(0.7,2.3),
+		bg=org.col,
+		fg=border,
+		...
+		)
+
+	for(p in 1:nrow(data))
+	{
+		for(h in 1:ncol(data))
+		{
+			if(data[p,h]>0)
+			{
+				arrows(pos.p[p],2,pos.h[h],1,lwd=(data[p,h]/1)*3+0.1,code=0)
+			}
+		}
+	}
+
+	symbols(
+		pos.p,
+		y = rep(2,length(pos.p)),
+		circles=rep(0.4,length(pos.p)),
+		inches=FALSE,
+		add=TRUE,
+		bg=org.col,
+		fg=border,
+		main='Réseau',
+		xlab='',
+		ylab=''
+		)
+	symbols(
+		pos.h,
+		y = rep(1,length(pos.h)),
+		circles=rep(0.4,length(pos.h)),
+		inches=FALSE,
+		add=TRUE,
+		bg=res.col,
+		fg=border
+		)
+}
\ No newline at end of file

Modified: pkg/ESM/R/functions.r
===================================================================
--- pkg/ESM/R/functions.r	2009-11-11 22:21:02 UTC (rev 7)
+++ pkg/ESM/R/functions.r	2009-11-12 09:44:40 UTC (rev 8)
@@ -114,101 +114,4 @@
 	out <- measure(mat)
 	names(out) <- rownames(mat)
 	return(out)
-}
-
-std.matrix <- function(filename,t=TRUE)
-{
-	dat <- read.table(filename)
-	if(t){dat<-t(dat)}
-	dat <- dat/max(dat)
-	return(dat)
-}
-
-GDS <- function(mat)
-{
-	D <- dim(mat)
-	N <- prod(D)
-	Ni <- sum(mat>0)/N
-	out <- NULL
-	out$RES <- D[1]
-	out$ORGA <- D[2]
-	out$SIZE <- N
-	out$COMP <- Ni
-	return(out)
-}
-
-sortmat.byspe <- function(mat,spe)
-{
-	mat[rank(spe),] <- mat[c(1:nrow(mat)),]
-	return(mat)
-}
-
-draw.network <- function(data,org.col='grey',res.col='grey',border=NA,sortorg=c(1:nrow(data)),sortres=c(1:ncol(data)),...)
-{
-	
-	data <- sortmat.byspe(data,sortorg)
-	data <- t(sortmat.byspe(t(data),sortres))
-	
-	n.elements <- max(dim(data))
-	
-	pos.h <- seq(from=1,to=n.elements,length.out=ncol(data))
-	pos.p <- seq(from=1,to=n.elements,length.out=nrow(data))
-	
-	par(bty='n',xaxt='n',yaxt='n')
-	symbols(
-		pos.p,
-		y = rep(2,length(pos.p)),
-		circles=rep(0.3,length(pos.p)),
-		inches=FALSE,
-		add=FALSE,
-		ylim=c(0.7,2.3),
-		bg=org.col,
-		fg=border,
-		...
-		)
-
-	for(p in 1:nrow(data))
-	{
-		for(h in 1:ncol(data))
-		{
-			if(data[p,h]>0)
-			{
-				arrows(pos.p[p],2,pos.h[h],1,lwd=(data[p,h]/1)*3+0.1,code=0)
-			}
-		}
-	}
-
-	symbols(
-		pos.p,
-		y = rep(2,length(pos.p)),
-		circles=rep(0.4,length(pos.p)),
-		inches=FALSE,
-		add=TRUE,
-		bg=org.col,
-		fg=border,
-		main='Réseau',
-		xlab='',
-		ylab=''
-		)
-	symbols(
-		pos.h,
-		y = rep(1,length(pos.h)),
-		circles=rep(0.4,length(pos.h)),
-		inches=FALSE,
-		add=TRUE,
-		bg=res.col,
-		fg=border
-		)
-}
-
-matrix.hr <- function(matrix)
-{
-	for(c in 1:ncol(matrix))
-	{
-		for(r in 1:nrow(matrix))
-		{
-			if(matrix[r,c]>0){matrix[r,c]<-1}
-		}
-	}
-	return(matrix)
 }
\ No newline at end of file

Added: pkg/ESM/R/matrix.hr.r
===================================================================
--- pkg/ESM/R/matrix.hr.r	                        (rev 0)
+++ pkg/ESM/R/matrix.hr.r	2009-11-12 09:44:40 UTC (rev 8)
@@ -0,0 +1,11 @@
+matrix.hr <- function(matrix)
+{
+	for(c in 1:ncol(matrix))
+	{
+		for(r in 1:nrow(matrix))
+		{
+			if(matrix[r,c]>0){matrix[r,c]<-1}
+		}
+	}
+	return(matrix)
+}
\ No newline at end of file

Added: pkg/ESM/R/sortmat.byspe.r
===================================================================
--- pkg/ESM/R/sortmat.byspe.r	                        (rev 0)
+++ pkg/ESM/R/sortmat.byspe.r	2009-11-12 09:44:40 UTC (rev 8)
@@ -0,0 +1,5 @@
+sortmat.byspe <- function(mat,spe)
+{
+	mat[rank(spe),] <- mat[c(1:nrow(mat)),]
+	return(mat)
+}
\ No newline at end of file

Added: pkg/ESM/R/std.matrix.r
===================================================================
--- pkg/ESM/R/std.matrix.r	                        (rev 0)
+++ pkg/ESM/R/std.matrix.r	2009-11-12 09:44:40 UTC (rev 8)
@@ -0,0 +1,7 @@
+std.matrix <- function(filename,t=TRUE)
+{
+	dat <- read.table(filename)
+	if(t){dat<-t(dat)}
+	dat <- dat/max(dat)
+	return(dat)
+}
\ No newline at end of file



More information about the Esm-commits mailing list