[Stpp-commits] r29 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 12 16:26:43 CET 2010


Author: gabriele
Date: 2010-02-12 16:26:42 +0100 (Fri, 12 Feb 2010)
New Revision: 29

Added:
   pkg/R/as.3dpoints.R
   pkg/R/is.3dpoints.R
   pkg/R/plot.stpp.R
   pkg/man/as.3dpoints.RD
   pkg/man/is.3dpoints.RD
   pkg/man/plot.stpp.RD
Log:


Added: pkg/R/as.3dpoints.R
===================================================================
--- pkg/R/as.3dpoints.R	                        (rev 0)
+++ pkg/R/as.3dpoints.R	2010-02-12 15:26:42 UTC (rev 29)
@@ -0,0 +1,52 @@
+as.3dpoints <- function (...) 
+{
+    nv <- nargs()
+    fargs <- list(...)
+    if (nv == 3) {
+        l1 <- length(fargs[[1]])
+        l2 <- length(fargs[[2]])
+        l3 <- length(fargs[[3]])
+        if ((l1 == l2) & (l1 == l3)) {
+            pts <- cbind(x=fargs[[1]], y=fargs[[2]], t=fargs[[3]])
+        }
+        else {
+            stop("Cannot make points from different length vectors")
+        }
+    }
+    else {
+        if (nv == 1) {
+            if (is.list(fargs[[1]])) {
+                fargs <- fargs[[1]]
+                if (any(names(fargs) == "x") & any(names(fargs) == 
+                  "y") & any(names(fargs) == "t")) {
+                  arx <- fargs$x
+                  ary <- fargs$y
+			art <- fargs$t
+                  if ((length(arx) != length(ary)) | (length(arx) != length(art))) {
+                    stop("Cannot make points from different length x, y and t list components!")
+                  }
+                  else {
+                    pts <- cbind(x=arx, y=ary, t=art)
+                  }
+                }
+                else {
+                  stop("Cannot make points from list without x and y components.")
+                }
+            }
+            else {
+                if (is.3dpoints(fargs[[1]])) 
+                  {
+				pts <- fargs[[1]]
+				colnames(pts)=c("x","y","t")	
+			}
+			
+                else stop("Cannot make points from this object")
+            }
+        }
+        else {
+            stop("Cannot make object into points!")
+        }
+    }
+    oldClass(pts)="stpp"
+    pts
+}

Added: pkg/R/is.3dpoints.R
===================================================================
--- pkg/R/is.3dpoints.R	                        (rev 0)
+++ pkg/R/is.3dpoints.R	2010-02-12 15:26:42 UTC (rev 29)
@@ -0,0 +1,9 @@
+is.3dpoints <- function (p) 
+{
+    is <- FALSE
+    	if (is.array(p)) 
+      	  if (length(dim(p)) == 2) 
+            	if (dim(p)[2] >= 3) 
+                	is <- TRUE
+    is
+}

Added: pkg/R/plot.stpp.R
===================================================================
--- pkg/R/plot.stpp.R	                        (rev 0)
+++ pkg/R/plot.stpp.R	2010-02-12 15:26:42 UTC (rev 29)
@@ -0,0 +1,19 @@
+
+plot.stpp <- function(x, s.region=NULL, t.region=NULL, ...)
+{
+if (inherits(x,"stpp")==TRUE) 
+	{ 
+	  par(mfrow=c(1,2),pty="s")
+	  if (is.null(s.region))	
+	  plot(x[,1:2],pch=20,main="xy-locations")
+	  else
+		{
+		  polymap(s.region,xlab="x",ylab="y")
+		  points(x[,1:2],pch=20)
+		  title("xy-locations")	 
+		}
+	  plot(x[,3],cumsum(x[,3]),type="l",xlab="t",ylab="",main="cumulative number",las=1,xlim=t.region)
+ 	}
+}
+getS3method("plot", "stpp", optional = FALSE)
+

Added: pkg/man/as.3dpoints.RD
===================================================================
--- pkg/man/as.3dpoints.RD	                        (rev 0)
+++ pkg/man/as.3dpoints.RD	2010-02-12 15:26:42 UTC (rev 29)
@@ -0,0 +1,27 @@
+\name{as.3dpoints}
+\alias{as.3dpoints}
+\title{Creates data in spatio-temporal point format}
+
+\description{
+Creates data in spatio-temporal point format.}
+
+\usage{
+as.3dpoints(...)
+}
+
+\arguments{
+  \item{...}{any object(s), such as x, y and t vectors of the same length, 
+  or a list or data frame containing x, y and t vectors. Valid options for 
+  ... are: a points object ; returns it unaltered; a list with x, y and t 
+  elements of the same length — returns a points object with the x, y and t 
+  elements as the coordinates of the points; three vectors of equal length ; 
+  returns a points object with the first vector as the x coordinates, the 
+  second vector as the y-coordinates and the third vector as the t-coordinates. }
+ }
+
+\value{
+The output is an object of the class \code{stpp}.
+as.3dpoints tries to return the argument(s) as a spatio-temporal points object.
+}
+
+\author{Edith Gabriel <edith.gabriel at univ-avignon.fr>, Peter Diggle, Barry Rowlingson.}

Added: pkg/man/is.3dpoints.RD
===================================================================
--- pkg/man/is.3dpoints.RD	                        (rev 0)
+++ pkg/man/is.3dpoints.RD	2010-02-12 15:26:42 UTC (rev 29)
@@ -0,0 +1,19 @@
+\name{is.3dpoints}
+\alias{is.3dpoints}
+\title{Spatio-temporal point objects}
+
+\description{
+Tests for data in spatio-temporal point format.}
+
+\usage{
+is.3dpoints(p)
+}
+
+\arguments{
+  \item{p}{any object.}
+ }
+
+\value{
+is.3dpoints returns TRUE if p is a spatio-temporal points object, FALSE otherwise. }
+
+\author{Edith Gabriel <edith.gabriel at univ-avignon.fr>, Peter Diggle, Barry Rowlingson.}

Added: pkg/man/plot.stpp.RD
===================================================================
--- pkg/man/plot.stpp.RD	                        (rev 0)
+++ pkg/man/plot.stpp.RD	2010-02-12 15:26:42 UTC (rev 29)
@@ -0,0 +1,28 @@
+\name{plot.stpp}
+\alias{plot.stpp}
+\title{Plot for spatio-temporal point objects}
+
+\description{
+This function plot xy-locations and cumulative distribution of the times.}
+
+\usage{
+## S3 method for class 'stpp':
+plot(p, s.region=NULL, t.region=NULL)
+}
+
+\arguments{
+  \item{p}{any object of class \code{stpp} in spatio-temporal point format.}
+  \item{s.region}{two-column matrix specifying polygonal region containing
+  all data locations. If \code{s.region} is missing, the default limits are considered.} 
+  \item{t.region}{vector containing the minimum and maximum values of
+  the time interval. If \code{t.region} is missing,  the default limits are considered.}
+ }
+
+\value{
+None
+
+\seealso{
+ \code{\link{as.3dpoints}} for creating data in spatio-temporal point format.
+ }
+
+\author{Edith Gabriel <edith.gabriel at univ-avignon.fr>.}



More information about the Stpp-commits mailing list