From 4271c72c0641033255e7f96e7fc0ca5dffeb1fea Mon Sep 17 00:00:00 2001
From: Philippe Verley <philippe.verley@ird.fr>
Date: Wed, 28 Mar 2018 13:57:21 +0000
Subject: [PATCH] Updated NAMESPACE to pass new R version of R CMD check. Made
 S3method declaration explicitly.

---
 DESCRIPTION      |   4 +-
 NAMESPACE        |  79 +++++++++++++++++++++++++-
 R/plot.fads.R    |   2 +-
 R/print.fads.R   |   7 ++-
 R/print.vads.R   | 144 +++++++++++++++++++++++------------------------
 R/summary.vads.R |   2 +-
 R/triangulate.R  |   2 +-
 7 files changed, 160 insertions(+), 80 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index cd85fe7..bb8f435 100755
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
 Package: ads
 Type: Package
 Title: Spatial point patterns analysis
-Version: 1.5-2.2
-Date: 2015-01-13
+Version: 1.5-3
+Date: 2018-03-28
 Author: R. Pelissier and F. Goreaud
 Maintainer: Raphael Pelissier <Raphael.Pelissier@ird.fr>
 Imports: ade4, spatstat
diff --git a/NAMESPACE b/NAMESPACE
index 7f723b7..c225fe8 100755
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,8 +1,83 @@
 # Import external pkg names
-# import(ade4, spatstat)
 importFrom(ade4,"divc","is.euclid")
 importFrom(spatstat,"border","bounding.box.xy","area.owin")
+importFrom("graphics", "abline", "barplot", "layout", "lines", "par",
+             "plot", "plot.default", "points", "polygon", "symbols",
+             "text")
+  importFrom("stats", "as.dist", "var")
+  importFrom("utils", "read.table", "str")
+
 # Export all names (should be improved in the future)
-exportPattern(".")
+export(
+	k12fun,
+	k12val,
+	kdfun,
+	kfun,
+	kmfun,
+	kp.fun,
+	kpqfun,
+	krfun,
+	ksfun,
+	kval,
+	
+	swin,
+	area.swin,
+	inside.swin,
+	ppp2spp,
+	dval,
+	mimetic,
+	owin2swin,
+	spp,
+	triangulate
+)
+
+exportClasses(
+	fads,
+	mimetic,
+	spp,
+	swin,
+	vads
+)
+
+S3method(plot, kfun, plot.fads.kfun)
+S3method(plot, kdfun, plot.fads.kdfun)
+S3method(plot, k12fun, plot.fads.k12fun)
+S3method(plot, kpqfun, plot.fads.kpqfun)
+S3method(plot, kp.fun, plot.fads.kp.fun)
+S3method(plot, kmfun, plot.fads.kmfun)
+S3method(plot, ksfun, plot.fads.ksfun)
+S3method(plot, krfun, plot.fads.krfun)
+S3method(plot, mimetic)
+S3method(plot, spp)
+S3method(plot, swin)
+S3method(plot, dval, plot.vads.dval)
+S3method(plot, k12val, plot.vads.k12val)
+S3method(plot, kval, plot.vads.kval)
+
+S3method(print, kfun, print.fads.kfun)
+S3method(print, kdfun, print.fads.kdfun)
+S3method(print, k12fun, print.fads.k12fun)
+S3method(print, kpqfun, print.fads.kpqfun)
+S3method(print, kp.fun, print.fads.kp.fun)
+S3method(print, kmfun, print.fads.kmfun)
+S3method(print, ksfun, print.fads.ksfun)
+S3method(print, krfun, print.fads.krfun)
+S3method(print, spp)
+S3method(print, swin)
+S3method(print, dval, print.vads.dval)
+S3method(print, k12val, print.vads.k12val)
+S3method(print, kval, print.vads.kval)
+S3method(print, summary.dval)
+S3method(print, summary.k12val)
+S3method(print, summary.kval)
+S3method(print, summary.spp)
+S3method(print, summary.swin)
+
+S3method(summary, spp)
+S3method(summary, swin)
+S3method(summary, dval, summary.vads.dval)
+S3method(summary, k12val, summary.vads.k12val)
+S3method(summary, kval, summary.vads.kval)
+
 # load DLL
 useDynLib(ads)
diff --git a/R/plot.fads.R b/R/plot.fads.R
index badaf43..7f932b8 100755
--- a/R/plot.fads.R
+++ b/R/plot.fads.R
@@ -1,5 +1,5 @@
 plot.fads<-function (x,opt,cols,lty,main,sub,legend,csize,...) {
-	UseMethod("plot.fads")
+  NextMethod()
 }
 
 plot.fads.kfun<-function (x,opt=c("all","L","K","n","g"),cols,lty,main,sub,legend=TRUE,csize=1,...) {
diff --git a/R/print.fads.R b/R/print.fads.R
index 59708fa..23142c8 100755
--- a/R/print.fads.R
+++ b/R/print.fads.R
@@ -1,5 +1,5 @@
 print.fads<-function(x,...) {
-	UseMethod("print.fads")
+	NextMethod()
 }
 
 print.fads.kfun<-function(x,...) {
@@ -7,6 +7,11 @@ print.fads.kfun<-function(x,...) {
 	str(x)	
 }
 
+print.fads.kdfun<-function(x,...) {
+  cat("Multiscale second-order neigbourhood analysis of a spatial phylogenetic or functional diversity pattern from fully mapped data:\n")
+  str(x)   
+}
+
 print.fads.k12fun<-function(x,...) {
 	cat("Bivariate second-order neighbourhood functions:\n")
 	str(x)	
diff --git a/R/print.vads.R b/R/print.vads.R
index b2587a3..bf8f38f 100755
--- a/R/print.vads.R
+++ b/R/print.vads.R
@@ -1,72 +1,72 @@
-print.vads<-function(x,...) {
-	UseMethod("print.vads")
-}
-
-print.vads.dval<-function(x,...) {
-	cat("First-order local density values:\n")
-	str(x)
-	#cat("class: ",class(x),"\n")
-    #cat("call: ")
-	#print(x$call)
-	#cat("sampling window :",x$window$type,"\n")
-	#cat("\n")
-	#sumry <- array("", c(1, 4), list(1:1, c("vector", "length", "mode", "content")))
-	#sumry[1, ] <- c("$r", length(x$r), mode(x$r), "distance (r)")
-	#class(sumry) <- "table"
-    #print(sumry)
-	#cat("\n")
-	#sumry <- array("", c(3, 4), list(1:3, c("matrix", "nrow", "ncol", "content")))
-    #sumry[1, ] <- c("$grid", nrow(x$grid), ncol(x$grid), "(x,y) coordinates of the sampling points A")
-	#sumry[2, ] <- c("$count", nrow(x$count), ncol(x$count), "counting function NA(r)")
-	#sumry[3, ] <- c("$density", nrow(x$dens), ncol(x$dens), "local density function nA(r)")
-	#class(sumry) <- "table"
-    #print(sumry)
-}
-
-print.vads.kval<-function(x,...) {
-	cat("Univariate second-order local neighbourhood values:\n")
-	str(x)
-	#cat("class: ",class(x),"\n")
-    #cat("call: ")
-	#print(x$call)
-	#cat("\n")
-	#sumry <- array("", c(1, 4), list(1:1, c("vector", "length", "mode", "content")))
-	#sumry[1, ] <- c("$r", length(x$r), mode(x$r), "distance (r)")
-	#class(sumry) <- "table"
-    #print(sumry)
-	#cat("\n")
-	#sumry <- array("", c(5, 4), list(1:5, c("matrix", "nrow", "ncol", "content")))
-    #sumry[1, ] <- c("$coord", nrow(x$coord), ncol(x$coord), "(x,y) coordinates of points i")
-	#sumry[2, ] <- c("$gi", nrow(x$gi), ncol(x$gi), "individual pair density values gi(r)")
-	#sumry[3, ] <- c("$ni", nrow(x$ni), ncol(x$ni), "individual local neighbour density values ni(r)")
-	#sumry[4, ] <- c("$ki", nrow(x$ki), ncol(x$ki), "individual Ripley's values Ki(r)")
-	#sumry[5, ] <- c("$li", nrow(x$li), ncol(x$li), "modified individual Ripley's values Li(r)")
-	#class(sumry) <- "table"
-    #print(sumry)
-}
-
-print.vads.k12val<-function(x,...) {
-	#verifyclass(x,"k12ival")
-	cat("Bivariate second-order local neighbourhood values:\n")
-	str(x)
-	#cat("class: ",class(x),"\n")
-    #cat("call: ")
-	#print(x$call)
-	#cat("mark1: ",x$marks[1],"\n")
-	#cat("mark2: ",x$marks[2],"\n")
-	#cat("\n")
-	#sumry <- array("", c(1, 4), list(1:1, c("vector", "length", "mode", "content")))
-	#sumry[1, ] <- c("$r", length(x$r), mode(x$r), "distance (r)")
-	#class(sumry) <- "table"
-    #print(sumry)
-	#cat("\n")
-	#sumry <- array("", c(5, 4), list(1:5, c("matrix", "nrow", "ncol", "content")))
-    #sumry[1, ] <- c("$coord1", nrow(x$coord1), ncol(x$coord1), "(x,y) coordinates of points of mark 1")
-	#sumry[2, ] <- c("$g12i", nrow(x$g12i), ncol(x$g12i), "individual pair density values g12i(r)")
-	#sumry[3, ] <- c("$n12i", nrow(x$n12i), ncol(x$n12i), "individual local neighbour density values n12i(r)")
-	#sumry[4, ] <- c("$k12i", nrow(x$k12i), ncol(x$k12i), "individual intertype values K12i(r)")
-	#sumry[5, ] <- c("$l12i", nrow(x$l12i), ncol(x$l12i), "modified intrtype Ripley's values L12i(r)")
-	#class(sumry) <- "table"
-    #print(sumry)
-}
-
+print.vads<-function(x,...) {
+  NextMethod()
+}
+
+print.vads.dval<-function(x,...) {
+	cat("First-order local density values:\n")
+	str(x)
+	#cat("class: ",class(x),"\n")
+    #cat("call: ")
+	#print(x$call)
+	#cat("sampling window :",x$window$type,"\n")
+	#cat("\n")
+	#sumry <- array("", c(1, 4), list(1:1, c("vector", "length", "mode", "content")))
+	#sumry[1, ] <- c("$r", length(x$r), mode(x$r), "distance (r)")
+	#class(sumry) <- "table"
+    #print(sumry)
+	#cat("\n")
+	#sumry <- array("", c(3, 4), list(1:3, c("matrix", "nrow", "ncol", "content")))
+    #sumry[1, ] <- c("$grid", nrow(x$grid), ncol(x$grid), "(x,y) coordinates of the sampling points A")
+	#sumry[2, ] <- c("$count", nrow(x$count), ncol(x$count), "counting function NA(r)")
+	#sumry[3, ] <- c("$density", nrow(x$dens), ncol(x$dens), "local density function nA(r)")
+	#class(sumry) <- "table"
+    #print(sumry)
+}
+
+print.vads.kval<-function(x,...) {
+	cat("Univariate second-order local neighbourhood values:\n")
+	str(x)
+	#cat("class: ",class(x),"\n")
+    #cat("call: ")
+	#print(x$call)
+	#cat("\n")
+	#sumry <- array("", c(1, 4), list(1:1, c("vector", "length", "mode", "content")))
+	#sumry[1, ] <- c("$r", length(x$r), mode(x$r), "distance (r)")
+	#class(sumry) <- "table"
+    #print(sumry)
+	#cat("\n")
+	#sumry <- array("", c(5, 4), list(1:5, c("matrix", "nrow", "ncol", "content")))
+    #sumry[1, ] <- c("$coord", nrow(x$coord), ncol(x$coord), "(x,y) coordinates of points i")
+	#sumry[2, ] <- c("$gi", nrow(x$gi), ncol(x$gi), "individual pair density values gi(r)")
+	#sumry[3, ] <- c("$ni", nrow(x$ni), ncol(x$ni), "individual local neighbour density values ni(r)")
+	#sumry[4, ] <- c("$ki", nrow(x$ki), ncol(x$ki), "individual Ripley's values Ki(r)")
+	#sumry[5, ] <- c("$li", nrow(x$li), ncol(x$li), "modified individual Ripley's values Li(r)")
+	#class(sumry) <- "table"
+    #print(sumry)
+}
+
+print.vads.k12val<-function(x,...) {
+	#verifyclass(x,"k12ival")
+	cat("Bivariate second-order local neighbourhood values:\n")
+	str(x)
+	#cat("class: ",class(x),"\n")
+    #cat("call: ")
+	#print(x$call)
+	#cat("mark1: ",x$marks[1],"\n")
+	#cat("mark2: ",x$marks[2],"\n")
+	#cat("\n")
+	#sumry <- array("", c(1, 4), list(1:1, c("vector", "length", "mode", "content")))
+	#sumry[1, ] <- c("$r", length(x$r), mode(x$r), "distance (r)")
+	#class(sumry) <- "table"
+    #print(sumry)
+	#cat("\n")
+	#sumry <- array("", c(5, 4), list(1:5, c("matrix", "nrow", "ncol", "content")))
+    #sumry[1, ] <- c("$coord1", nrow(x$coord1), ncol(x$coord1), "(x,y) coordinates of points of mark 1")
+	#sumry[2, ] <- c("$g12i", nrow(x$g12i), ncol(x$g12i), "individual pair density values g12i(r)")
+	#sumry[3, ] <- c("$n12i", nrow(x$n12i), ncol(x$n12i), "individual local neighbour density values n12i(r)")
+	#sumry[4, ] <- c("$k12i", nrow(x$k12i), ncol(x$k12i), "individual intertype values K12i(r)")
+	#sumry[5, ] <- c("$l12i", nrow(x$l12i), ncol(x$l12i), "modified intrtype Ripley's values L12i(r)")
+	#class(sumry) <- "table"
+    #print(sumry)
+}
+
diff --git a/R/summary.vads.R b/R/summary.vads.R
index e617af1..a5b9d0d 100755
--- a/R/summary.vads.R
+++ b/R/summary.vads.R
@@ -1,5 +1,5 @@
 summary.vads<-function(object,...) {
-	UseMethod("summary.vads")
+  NextMethod()
 }
 
 summary.vads.dval<-function (object,...) {
diff --git a/R/triangulate.R b/R/triangulate.R
index 5b05a24..9453bae 100755
--- a/R/triangulate.R
+++ b/R/triangulate.R
@@ -29,7 +29,7 @@ triangulate<-function(outer.poly,holes) {
 	else {
 		# phv 20160823 bug fix: triangulate C function crashes with 4 points polygons and no hole
 		# Bypass the C function and returns 2 triangles made respectively of vertices (1, 2, 3) and (1, 3, 4)
-		if(nrow(outer.poly)==4) {
+		if(length(outer.poly$x)==4) {
 			return(data.frame(
 				ax=c(outer.poly$x[1], outer.poly$x[1]),
 				ay=c(outer.poly$y[1], outer.poly$y[1]),
-- 
GitLab