[Phylobase-commits] r868 - in pkg: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Mar 14 21:36:31 CET 2014
Author: francois
Date: 2014-03-14 21:36:31 +0100 (Fri, 14 Mar 2014)
New Revision: 868
Removed:
pkg/misc/
Modified:
pkg/R/pdata.R
Log:
moving chunk of code that was in non-standard folder
Modified: pkg/R/pdata.R
===================================================================
--- pkg/R/pdata.R 2014-03-14 20:31:35 UTC (rev 867)
+++ pkg/R/pdata.R 2014-03-14 20:36:31 UTC (rev 868)
@@ -2,6 +2,20 @@
ptypes <- c("multitype","binary","continuous","DNA","RNA","aacid",
"other","unknown")
+#' Class "pdata"
+#'
+#' Data class for phylo4d objects
+#'
+#'
+#' @name pdata-class
+#' @aliases ptypes pdata-class [<-,pdata-method [,pdata-method
+#' [,pdata,ANY,ANY,ANY-method [[,pdata-method [[<-,pdata-method
+#' [[,pdata,ANY,ANY-method [[,pdata,ANY,missing-method
+#' @docType class
+#' @section Objects from the Class: Objects can be created by calls of the form
+#' \code{new("pdata", ...)}.
+#' @author Ben Bolker
+#' @keywords classes
setClass("pdata", representation(data="data.frame",
type="factor",
comment="character",
@@ -10,6 +24,25 @@
comment=character(0),metadata=list()))
## pdata constructor
+
+
+#' Constructor for pdata (phylogenetic data) class
+#'
+#' Combine data, type, comments, and metadata information to create a new pdata
+#' object, or check such an object for consistency
+#'
+#'
+#' @aliases pdata check_pdata
+#' @param data a data frame
+#' @param type a factor with levels as specified by \linkS4class{pdata}, the
+#' same length as \code{ncol(data)}
+#' @param comment a character vector, the same length as \code{ncol(data)}
+#' @param metadata an arbitrary list
+#' @param object an object of class \code{pdata}
+#' @return An object of class \code{pdata}
+#' @author Ben Bolker
+#' @seealso \linkS4class{pdata}
+#' @keywords misc
pdata <- function(data,type,comment,metadata) {
nvar <- ncol(data)
if (missing(type)) {
@@ -72,4 +105,39 @@
## z[,"a"]
## z[[2]]
-## test conflict resolution error
\ No newline at end of file
+## test conflict resolution error
+
+#######
+### old code retrieved from misc/ folder
+
+## setClass("pdata", representation(x="vector", y="vector"))
+## setMethod("[","pdata",function(x,i, j,...,drop=TRUE)new("pdata",x=x at x[i],y=x at y[i]))
+
+# x <- new("pdata", x=c("a","b", "c", "d", "3"), y=c(1:5))
+#>x[c(2,4)]
+#An object of class “pdata”
+#Slot "x":
+#[1] "b" "d"
+#
+#Slot "y":
+#[1] 2 4
+
+
+
+# doesn't work
+#setClass("track", representation("list", comment="character", metadata="vector"), contains="list", prototype(list(), comment="", metadata=NA))
+#setMethod("[","track",function(x,i, j,...,drop=TRUE)new("track", list(lapply(x, function(x, i, j, ..., drop=TRUE) x at .Data[i]))))
+
+# this works, how to incorporate into method above?
+#> lapply(x, function(x, i=2, j, ..., drop=TRUE) x at .Data[i])
+#$x
+#[1] "b"
+
+#$y
+#[1] 2
+
+# this works, but list structure is destroyed
+#> mapply(function(x, i, j, ..., drop=TRUE) x at .Data[i], x, 2)
+# x y
+#"b" "2"
+
More information about the Phylobase-commits
mailing list