Thread: [R-gregmisc-users] SF.net SVN: r-gregmisc: [957] trunk/gtools
Brought to you by:
warnes
From: <nj...@us...> - 2006-05-05 16:55:35
|
Revision: 957 Author: nj7w Date: 2006-05-05 09:55:31 -0700 (Fri, 05 May 2006) ViewCVS: http://svn.sourceforge.net/r-gregmisc/?rev=957&view=rev Log Message: ----------- Fixed minor typos Modified Paths: -------------- trunk/gtools/NAMESPACE trunk/gtools/man/capture.Rd Modified: trunk/gtools/NAMESPACE =================================================================== --- trunk/gtools/NAMESPACE 2006-04-20 20:54:09 UTC (rev 956) +++ trunk/gtools/NAMESPACE 2006-05-05 16:55:31 UTC (rev 957) @@ -3,6 +3,7 @@ export( addLast, assert, + capture, combinations, ddirichlet, defmacro, @@ -23,6 +24,7 @@ running, scat, setTCPNoDelay, + sprint, strmacro ) Modified: trunk/gtools/man/capture.Rd =================================================================== --- trunk/gtools/man/capture.Rd 2006-04-20 20:54:09 UTC (rev 956) +++ trunk/gtools/man/capture.Rd 2006-05-05 16:55:31 UTC (rev 957) @@ -1,7 +1,7 @@ \name{capture} \alias{capture} \alias{sprint} -\title{Capture printed output of an R expression in a string}. +\title{Capture printed output of an R expression in a string} \description{ Capture printed output of an R expression in a string } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2006-11-27 21:34:11
|
Revision: 1019 http://svn.sourceforge.net/r-gregmisc/?rev=1019&view=rev Author: warnes Date: 2006-11-27 13:34:07 -0800 (Mon, 27 Nov 2006) Log Message: ----------- Add smartbind() to list of exported functions, and add corresponding documentation file. Modified Paths: -------------- trunk/gtools/DESCRIPTION trunk/gtools/NAMESPACE trunk/gtools/NEWS trunk/gtools/R/smartbind.R Added Paths: ----------- trunk/gtools/man/smartbind.Rd Modified: trunk/gtools/DESCRIPTION =================================================================== --- trunk/gtools/DESCRIPTION 2006-11-27 20:52:33 UTC (rev 1018) +++ trunk/gtools/DESCRIPTION 2006-11-27 21:34:07 UTC (rev 1019) @@ -1,8 +1,8 @@ Package: gtools Title: Various R programming tools Description: Various R programming tools -Depends: R (>= 1.9.0) -Version: 2.2.4 +Depends: R +Version: 2.3.0 Author: Gregory R. Warnes. Includes R source code and/or documentation contributed by Ben Bolker and Thomas Lumley Maintainer: Gregory R. Warnes <wa...@bs...> Modified: trunk/gtools/NAMESPACE =================================================================== --- trunk/gtools/NAMESPACE 2006-11-27 20:52:33 UTC (rev 1018) +++ trunk/gtools/NAMESPACE 2006-11-27 21:34:07 UTC (rev 1019) @@ -24,6 +24,7 @@ running, scat, setTCPNoDelay, + smartbind, sprint, strmacro ) Modified: trunk/gtools/NEWS =================================================================== --- trunk/gtools/NEWS 2006-11-27 20:52:33 UTC (rev 1018) +++ trunk/gtools/NEWS 2006-11-27 21:34:07 UTC (rev 1019) @@ -1,11 +1,19 @@ -CHANGES IN gtools 2.2.3 ------------------------ +gtools 2.3.0 +------------ +- Update email address for Greg + +- Add new 'smartbind' function, which combines data frames + efficiently, even if they have different column names. + +gtools 2.2.3 +------------ + - setTCPNoDelay now compiles & works properly on Windows -CHANGES IN gtools 2.2.2 ------------------------ +gtools 2.2.2 +------------ - src/setTCPNoDelay.c: Add C source code for setTCPNoDelay. @@ -14,8 +22,8 @@ - Updated Greg's email address. -CHANGES IN gtools 2.2.1 ------------------------ +gtools 2.2.1 +------------ - New function 'addLast' that adds functions to R's .Last() so that they will be executed when R is terminating. @@ -23,8 +31,8 @@ - New function setTCPNoDelay() that allows the TCP_NODELAY flag to be changed on socket objects. -CHANGES IN gtools 2.1.0 ------------------------ +gtools 2.1.0 +------------ - Added assert.R (and documentation) Modified: trunk/gtools/R/smartbind.R =================================================================== --- trunk/gtools/R/smartbind.R 2006-11-27 20:52:33 UTC (rev 1018) +++ trunk/gtools/R/smartbind.R 2006-11-27 21:34:07 UTC (rev 1019) @@ -10,7 +10,13 @@ data <- list(...) if(is.null(names(data))) names(data) <- as.character(1:length(data)) - data <- lapply(data, function(x) if(is.matrix(x) || is.data.frame(x)) x else data.frame(as.list(x)) ) + data <- lapply(data, + function(x) + if(is.matrix(x) || is.data.frame(x)) + x + else + data.frame(as.list(x)) + ) #retval <- new.env() retval <- list() @@ -33,7 +39,10 @@ { if( !(col %in% names(retval))) { - if(verbose) cat("Start:", start, " End:", end, " Column:", col, "\n", sep="") + if(verbose) cat("Start:", start, + " End:", end, + " Column:", col, + "\n", sep="") if(class(block[,col])=="factor") newclass <- "character" else @@ -53,38 +62,3 @@ return(retval) } -testfun <- function(n=10,s=10) - { - names <- unlist(outer(LETTERS,letters, paste, sep="")) - - Z <- list() - for(i in 1:n) - { - X <- data.frame(A=sample(letters,s,replace=T), - B=1:s, - C=rnorm(s) ) - names(X) <- c("A",sample(names[1:s*2],2,replace=F)) - Z[[i]] <- X - } - - - - #ut2 <- unix.time( - # retval2 <- do.call("rbind",Z) - # ) - # - #cat("rbind used",ut2[3], "seconds.\n") - - - ut1 <- unix.time( - retval1 <- do.call("smartbind",Z) - ) - - cat("smartbind used",ut1[3], "seconds.\n") - - - invisible(retval1) - } - - - Added: trunk/gtools/man/smartbind.Rd =================================================================== --- trunk/gtools/man/smartbind.Rd (rev 0) +++ trunk/gtools/man/smartbind.Rd 2006-11-27 21:34:07 UTC (rev 1019) @@ -0,0 +1,74 @@ +\name{smartbind} +\alias{smartbind} +\title{Efficient rbind of data framesy, even if the column names don't match} +\description{ + Efficient rbind of data frames, even if the column names don't match +} +\usage{ +smartbind(...) +} +\arguments{ + \item{\dots}{Data frames to combine} +} +\value{ + The returned data frame will contain: + \item{columns}{all columns present in any provided data frame} + \item{rows}{a set of rows from each provided data frame, with values + in columns not present in the given data frame filled with missing + (\code{NA}) values.} + The data type of columns will be preserved, as long as all data frames + with a given column name agree on the data type of that column. If + the data frames disagree, the column will be converted into a + character strings. The user will need to coerce such character + columns into an appropriate type. +} +\author{Gregory R. Warnes \email{wa...@bs...}} +\seealso{ \code{\link{rbind}}, \code{\link{cbind}} } +\examples{ + + df1 <- data.frame(A=1:10, B=LETTERS[1:10], C=rnorm(10) ) + df2 <- data.frame(A=11:20, D=rnorm(10), E=letters[1:10] ) + + # rbind would fail +\dontrun{ + rbind(df1, df2) + # Error in match.names(clabs, names(xi)) : names do not match previous + # names: + # D, E +} + # but smartbind combines them, appropriately creating NA entries + smartbind(df1, df2) + +\dontshow{ + n=10 # number of data frames to create + s=10 # number of rows in each data frame + + # create a bunch of column names + names <- LETTERS[2:5] + + # create a list 'Z' containing 'n' data frames, each with 3 columns + # and 's' rows. The first column is always named 'A', but the other + # two have a names randomly selected from 'names' + + Z <- list() + for(i in 1:n) + { + X <- data.frame(A=sample(letters,s,replace=T), + B=letters[1:s], + C=rnorm(s) ) + colnames(X) <- c("A",sample(names,2,replace=F)) + Z[[i]] <- X + } + + # Error in match.names(clabs, names(xi)) : names do not match + # previous names: E + + # But smartbind will 'do the right thing' + df <- do.call("smartbind",Z) + df +} +} +% Add one or more standard keywords, see file 'KEYWORDS' in the +% R documentation directory. +\keyword{manip} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-04-07 13:41:53
|
Revision: 1087 http://svn.sourceforge.net/r-gregmisc/?rev=1087&view=rev Author: warnes Date: 2007-04-07 06:41:51 -0700 (Sat, 07 Apr 2007) Log Message: ----------- Fix improper escapes in regexp detected by R 2.5.0 package check. Modified Paths: -------------- trunk/gtools/DESCRIPTION trunk/gtools/R/mixedsort.R Modified: trunk/gtools/DESCRIPTION =================================================================== --- trunk/gtools/DESCRIPTION 2007-03-24 21:31:01 UTC (rev 1086) +++ trunk/gtools/DESCRIPTION 2007-04-07 13:41:51 UTC (rev 1087) @@ -2,7 +2,7 @@ Title: Various R programming tools Description: Various R programming tools Depends: R -Version: 2.3.0 +Version: 2.3.1 Author: Gregory R. Warnes. Includes R source code and/or documentation contributed by Ben Bolker and Thomas Lumley Maintainer: Gregory R. Warnes <wa...@bs...> Modified: trunk/gtools/R/mixedsort.R =================================================================== --- trunk/gtools/R/mixedsort.R 2007-03-24 21:31:01 UTC (rev 1086) +++ trunk/gtools/R/mixedsort.R 2007-04-07 13:41:51 UTC (rev 1087) @@ -45,7 +45,7 @@ #### # find and mark numbers in the form of +1.23e+45.67 - delimited <- gsub("([+-]{0,1}[0-9\.]+([eE][\+\-]{0,1}[0-9\.]+){0,1})", + delimited <- gsub("([+-]{0,1}[0-9\\.]+([eE][\\+\\-]{0,1}[0-9\\.]+){0,1})", paste(delim,"\\1",delim,sep=""), x) # separate out numbers This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-04-12 21:17:00
|
Revision: 1088 http://svn.sourceforge.net/r-gregmisc/?rev=1088&view=rev Author: warnes Date: 2007-04-12 14:16:41 -0700 (Thu, 12 Apr 2007) Log Message: ----------- Add ask() function to prompt the user and collect a single response. Modified Paths: -------------- trunk/gtools/NAMESPACE trunk/gtools/NEWS Added Paths: ----------- trunk/gtools/R/ask.R trunk/gtools/man/ask.Rd Modified: trunk/gtools/NAMESPACE =================================================================== --- trunk/gtools/NAMESPACE 2007-04-07 13:41:51 UTC (rev 1087) +++ trunk/gtools/NAMESPACE 2007-04-12 21:16:41 UTC (rev 1088) @@ -2,6 +2,7 @@ export( addLast, + ask, assert, capture, combinations, Modified: trunk/gtools/NEWS =================================================================== --- trunk/gtools/NEWS 2007-04-07 13:41:51 UTC (rev 1087) +++ trunk/gtools/NEWS 2007-04-12 21:16:41 UTC (rev 1088) @@ -1,3 +1,9 @@ +SVN +---- + +- Add ask() function to prompt the user and collect a single response. + + gtools 2.3.0 ------------ Added: trunk/gtools/R/ask.R =================================================================== --- trunk/gtools/R/ask.R (rev 0) +++ trunk/gtools/R/ask.R 2007-04-12 21:16:41 UTC (rev 1088) @@ -0,0 +1,5 @@ +ask <- function(msg="Press <RETURN> to continue: ") + { + cat(msg); + readLines(con=stdin(),n=1) + } Added: trunk/gtools/man/ask.Rd =================================================================== --- trunk/gtools/man/ask.Rd (rev 0) +++ trunk/gtools/man/ask.Rd 2007-04-12 21:16:41 UTC (rev 1088) @@ -0,0 +1,36 @@ +\name{ask} +\alias{ask} +\title{Display a prompt and collect the user's response} +\description{ + Display a prompt and collect the user's response +} +\usage{ +ask(msg = "Press <RETURN> to continue: ") +} +\arguments{ + \item{msg}{Character vetor providing the message to be displayed} +} +\details{ + The prompt message will be displayed, and then \code{readLines} is + used to collect a single input value (possibly empty), which is then + returned. +} +\value{ + A character scalar containing the input providede by the user. +} +\author{Gregory R. Warnes \email{gr...@ra...}} +\seealso{ \code{\link{readLines}}, \code{\link{scan}} } +\examples{ + +# use default prompt +ask() + +silly <- function() +{ + age <- ask("How old aroe you? ") + age <- as.numeric(age) + cat("In 10 years you will be", age+10, "years old!\n") +} + +} +\keyword{IO} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-08 13:48:45
|
Revision: 1120 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1120&view=rev Author: warnes Date: 2007-08-08 06:48:43 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Add the binsearch(), previously in the genetics package. Modified Paths: -------------- trunk/gtools/DESCRIPTION trunk/gtools/NAMESPACE trunk/gtools/NEWS Added Paths: ----------- trunk/gtools/R/binsearch.R trunk/gtools/man/binsearch.Rd Modified: trunk/gtools/DESCRIPTION =================================================================== --- trunk/gtools/DESCRIPTION 2007-08-03 04:44:05 UTC (rev 1119) +++ trunk/gtools/DESCRIPTION 2007-08-08 13:48:43 UTC (rev 1120) @@ -2,7 +2,7 @@ Title: Various R programming tools Description: Various R programming tools Depends: R -Version: 2.3.1 +Version: 2.4.0 Author: Gregory R. Warnes. Includes R source code and/or documentation contributed by Ben Bolker and Thomas Lumley Maintainer: Gregory R. Warnes <wa...@bs...> Modified: trunk/gtools/NAMESPACE =================================================================== --- trunk/gtools/NAMESPACE 2007-08-03 04:44:05 UTC (rev 1119) +++ trunk/gtools/NAMESPACE 2007-08-08 13:48:43 UTC (rev 1120) @@ -4,6 +4,7 @@ addLast, ask, assert, + binsearch, capture, combinations, ddirichlet, Modified: trunk/gtools/NEWS =================================================================== --- trunk/gtools/NEWS 2007-08-03 04:44:05 UTC (rev 1119) +++ trunk/gtools/NEWS 2007-08-08 13:48:43 UTC (rev 1120) @@ -1,6 +1,12 @@ -SVN ----- +gtools 2.4.0 +------------ +- Add binsearch() function, previously in the genetics() package. + + +gtoosl 2.3.1 +------------ + - Add ask() function to prompt the user and collect a single response. Added: trunk/gtools/R/binsearch.R =================================================================== --- trunk/gtools/R/binsearch.R (rev 0) +++ trunk/gtools/R/binsearch.R 2007-08-08 13:48:43 UTC (rev 1120) @@ -0,0 +1,134 @@ +# $Id: binsearch.R 1295 2007-08-08 13:38:18Z warnes $ + +binsearch <- function(fun, range, ..., target=0, + lower=ceiling(min(range)),upper=floor(max(range)), + maxiter=100, showiter=FALSE) + { + + # initialize + lo <- lower + hi <- upper + counter <- 0 + val.lo <- fun(lo,...) + val.hi <- fun(hi,...) + + # check whether function is increasing or decreasing, & set sign + # appropriately. + if( val.lo > val.hi ) + sign <- -1 + else + sign <- 1 + + # check if value is outside specified range + if(target * sign < val.lo * sign) + outside.range <- TRUE + else if(target * sign > val.hi * sign) + outside.range <- TRUE + else + outside.range <- FALSE + + # iteratively move lo & high closer together until we run out of + # iterations, or they are adjacent, or they are identical + while(counter < maxiter && !outside.range ) + { + + counter <- counter+1 + + if(hi-lo<=1 || lo<lower || hi>upper) break; + + center <- round((hi - lo)/2 + lo ,0 ) + val <- fun(center, ...) + + if(showiter) + { + cat("--------------\n") + cat("Iteration #", counter, "\n") + cat("lo=",lo,"\n") + cat("hi=",hi,"\n") + cat("center=",center,"\n") + cat("fun(lo)=",val.lo,"\n") + cat("fun(hi)=",val.hi,"\n") + cat("fun(center)=",val,"\n") + } + + + if( val==target ) + { + val.lo <- val.hi <- val + lo <- hi <- center + break; + } + else if( sign*val < sign*target ) + { + lo <- center + val.lo <- val + } + else #( val > target ) + { + hi <- center + val.hi <- val + } + + if(showiter) + { + cat("new lo=",lo,"\n") + cat("new hi=",hi,"\n") + cat("--------------\n") + } + + } + + # Create return value + retval <- list() + retval$call <- match.call() + retval$numiter <- counter + + if( outside.range ) + { + if(target * sign < val.lo * sign) + { + warning("Reached lower boundary") + retval$flag="Lower Boundary" + retval$where=lo + retval$value=val.lo + } + else #(target * sign > val.hi * sign) + { + warning("Reached upper boundary") + retval$flag="Upper Boundary" + retval$where=hi + retval$value=val.hi + } + } + else if( counter >= maxiter ) + { + warning("Maximum number of iterations reached") + retval$flag="Maximum number of iterations reached" + retval$where=c(lo,hi) + retval$value=c(fun.lo,fun.hi) + } + else if( val.lo==target ) + { + retval$flag="Found" + retval$where=lo + retval$value=val.lo + } + else if( val.hi==target ) + { + retval$flag="Found" + retval$where=lo + retval$value=val.lo + } + else + { + retval$flag="Between Elements" + retval$where=c(lo, hi) + retval$value=c(val.lo, val.hi) + } + + return(retval) + + } + + + Added: trunk/gtools/man/binsearch.Rd =================================================================== --- trunk/gtools/man/binsearch.Rd (rev 0) +++ trunk/gtools/man/binsearch.Rd 2007-08-08 13:48:43 UTC (rev 1120) @@ -0,0 +1,103 @@ +% $Id: binsearch.Rd 1087 2006-11-11 04:09:59Z warnes $ + +\name{binsearch} +\alias{binsearch} +\title{Binary Search} +\description{ + Search within a specified range to locate an integer parameter which + results in the the specified monotonic function obtaining a given value. +} +\usage{ +binsearch(fun, range, ..., target = 0, lower = ceiling(min(range)), + upper = floor(max(range)), maxiter = 100, showiter = FALSE) +} +\arguments{ + \item{fun}{Monotonic function over which the search will be performed.} + \item{range}{2-element vector giving the range for the search.} + \item{\dots}{Additional parameters to the function \code{fun}.} + \item{target}{Target value for \code{fun}. Defaults to 0.} + \item{lower}{Lower limit of search range. Defaults to \code{min(range)}.} + \item{upper}{Upper limit of search range. Defaults to \code{max(range)}.} + \item{maxiter}{ Maximum number of search iterations. Defaults to 100.} + \item{showiter}{ Boolean flag indicating whether the algorithm state + should be printed at each iteration. Defaults to FALSE.} +} +\details{ + This function implements an extension to the standard binary search + algorithm for searching a sorted list. The algorithm has been + extended to cope with cases where an exact match is not possible, to + detect whether that the function may be monotonic increasing or + decreasing and act appropriately, and to detect when the target value + is outside the specified range. + + The algorithm initializes two variable \code{lo} and + \code{high} to the extremes values of \code{range}. It then generates + a new value \code{center} halfway between \code{lo} and \code{hi}. If + the value of \code{fun} at \code{center} exceeds \code{target}, it + becomes the new value for \code{lo}, otherwise it becomes the new + value for \code{hi}. This process is iterated until \code{lo} and + \code{hi} are adjacent. If the function at one or the other equals + the target, this value is returned, otherwise \code{lo}, \code{hi}, + and the function value at both are returned. + + Note that when the specified target value falls between integers, the + \em{two} closest values are returned. If the specified target falls + outside of the specified \code{range}, the closest endpoint of the + range will be returned, and an warning message will be generated. If + the maximum number if iterations was reached, the endpoints of the + current subset of the range under consideration will be returned. +} +\value{ + A list containing: + \item{call}{How the function was called.} + \item{numiter}{The number of iterations performed} + \item{flag }{One of the strings, "Found", "Between Elements", + "Maximum number of iterations reached", "Reached lower boundary", or + "Reached upper boundary."} + \item{where}{One or two values indicating where the search + terminated.} + \item{value}{Value of the function \code{fun} at the values of + \code{where}.} +} +%\references{ ~put references to the literature/web site here ~ } +\author{Gregory R. Warnes \email{wa...@bs...} } +\note{This function often returns two values for \code{where} and + \code{value}. Be sure to check the \code{flag} parameter to see what + these values mean.} +\seealso{ \code{\link[base]{optim}}, \code{\link[base]{optimize}}, + \code{\link[base]{uniroot}} } +\examples{ + +### Toy examples + +# search for x=10 +binsearch( function(x) x-10, range=c(0,20) ) + +# search for x=10.1 +binsearch( function(x) x-10.1, range=c(0,20) ) + +### Classical toy example + +# binary search for the index of 'M' among the sorted letters +fun <- function(X) ifelse(LETTERS[X] > 'M', 1, + ifelse(LETTERS[X] < 'M', -1, 0 ) ) + +binsearch( fun, range=1:26 ) +# returns $where=13 +LETTERS[13] + +### Substantive example, from genetics +\dontrun{ +library(genetics) +# Determine the necessary sample size to detect all alleles with +# frequency 0.07 or greater with probability 0.95. +power.fun <- function(N) 1 - gregorius(N=N, freq=0.07)$missprob + +binsearch( power.fun, range=c(0,100), target=0.95 ) + +# equivalent to +gregorius( freq=0.07, missprob=0.05) +} +} +\keyword{optimize} +\keyword{programming} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-08 13:52:48
|
Revision: 1121 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1121&view=rev Author: warnes Date: 2007-08-08 06:52:47 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Fix bug identified by R-2.6's check routings in binsearch() Modified Paths: -------------- trunk/gtools/DESCRIPTION trunk/gtools/R/binsearch.R Modified: trunk/gtools/DESCRIPTION =================================================================== --- trunk/gtools/DESCRIPTION 2007-08-08 13:48:43 UTC (rev 1120) +++ trunk/gtools/DESCRIPTION 2007-08-08 13:52:47 UTC (rev 1121) @@ -1,7 +1,6 @@ Package: gtools Title: Various R programming tools Description: Various R programming tools -Depends: R Version: 2.4.0 Author: Gregory R. Warnes. Includes R source code and/or documentation contributed by Ben Bolker and Thomas Lumley Modified: trunk/gtools/R/binsearch.R =================================================================== --- trunk/gtools/R/binsearch.R 2007-08-08 13:48:43 UTC (rev 1120) +++ trunk/gtools/R/binsearch.R 2007-08-08 13:52:47 UTC (rev 1121) @@ -105,7 +105,7 @@ warning("Maximum number of iterations reached") retval$flag="Maximum number of iterations reached" retval$where=c(lo,hi) - retval$value=c(fun.lo,fun.hi) + retval$value=c(val.lo,val.hi) } else if( val.lo==target ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2008-04-12 19:19:49
|
Revision: 1258 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1258&view=rev Author: warnes Date: 2008-04-12 12:19:45 -0700 (Sat, 12 Apr 2008) Log Message: ----------- assert() is now deprecated in favor of base::stopifnot() Modified Paths: -------------- trunk/gtools/NEWS Added Paths: ----------- trunk/gtools/man/assert-deprecated.R trunk/gtools/man/gtools-deprecated.Rd Removed Paths: ------------- trunk/gtools/man/assert.Rd Modified: trunk/gtools/NEWS =================================================================== --- trunk/gtools/NEWS 2008-04-12 19:19:05 UTC (rev 1257) +++ trunk/gtools/NEWS 2008-04-12 19:19:45 UTC (rev 1258) @@ -1,3 +1,9 @@ +gtools SVN VERSION $Id$ +----------------------- + +- Modify odd() and even() to use modulus operator instead of division. + (Doesn't seem to change the results, but looks more elegant!) + gtools 2.4.0 ------------ Copied: trunk/gtools/man/assert-deprecated.R (from rev 1256, trunk/gtools/man/assert.Rd) =================================================================== --- trunk/gtools/man/assert-deprecated.R (rev 0) +++ trunk/gtools/man/assert-deprecated.R 2008-04-12 19:19:45 UTC (rev 1258) @@ -0,0 +1,49 @@ +\name{assert-deprecated} +\alias{assert-deprecated} +\alias{assert} +\title{DEPRECATED: Generate an error if an expression is not true.} +\description{ + Generate an error if an expression is not true. +} +\note{ + This function is deprecated in favor of \code{\link[base]{stopifnot}} +} +\usage{ +assert(FLAG) +} +\arguments{ + \item{FLAG}{ Expression that should evaluate to a boolean vector} +} +\details{ + Assert generate an error if its aregument does not evaluate to + boolean (vector) containing only \code{TRUE} values. This is useful + for defensinve programming as it provides a mechanism for checking + that certain facts, the 'assertions', do in fact hold. Checking of + 'assertions' is an important tool in the development of robust program + code. +} +\value{ + None. Evaluated only for its side effect. +} +\author{Gregory R. Warnes \email{wa...@bs...} } +\seealso{ + \code{\link[base]{stopifnot}}, \code{\link[base]{stop}}, + \code{\link[base]{warning}} +} +\examples{ + +## Trivial example +posSqrt <- function(x) + { + assert(x>=0) + sqrt(x) + } + +posSqrt(1:10) # works fine, no messages +\dontrun{ +posSqrt(-5:5) # generates an error, since the asssertion is not met +} + + +} +\keyword{programming} Deleted: trunk/gtools/man/assert.Rd =================================================================== --- trunk/gtools/man/assert.Rd 2008-04-12 19:19:05 UTC (rev 1257) +++ trunk/gtools/man/assert.Rd 2008-04-12 19:19:45 UTC (rev 1258) @@ -1,42 +0,0 @@ -\name{assert} -\alias{assert} -\title{Generate an error if an expression is not true.} -\description{ - Generate an error if an expression is not true. -} -\usage{ -assert(FLAG) -} -\arguments{ - \item{FLAG}{ Expression that should evaluate to a boolean vector} -} -\details{ - Assert generate an error if its aregument does not evaluate to - boolean (vector) containing only \code{TRUE} values. This is useful - for defensinve programming as it provides a mechanism for checking - that certain facts, the 'assertions', do in fact hold. Checking of - 'assertions' is an important tool in the development of robust program - code. -} -\value{ - None. Evaluated only for its side effect. -} -\author{Gregory R. Warnes \email{wa...@bs...} } -\seealso{ \code{\link[base]{stop}}, \code{\link[base]{warning}} } -\examples{ - -## Trivial example -posSqrt <- function(x) - { - assert(x>=0) - sqrt(x) - } - -posSqrt(1:10) # works fine, no messages -\dontrun{ -posSqrt(-5:5) # generates an error, since the asssertion is not met -} - - -} -\keyword{programming} Added: trunk/gtools/man/gtools-deprecated.Rd =================================================================== --- trunk/gtools/man/gtools-deprecated.Rd (rev 0) +++ trunk/gtools/man/gtools-deprecated.Rd 2008-04-12 19:19:45 UTC (rev 1258) @@ -0,0 +1,24 @@ +\name{gtools-deprecated} +\alias{gtools-deprecated} +\alias{assert} +\title{Deprecated Functions in the gtools package} +\description{ + These functions are provided for compatibility with older versions of + gtools, and may be defunct as soon as the next release. +} +\usage{ +assert(FLAG) +} +\arguments{ + \item{FLAG}{ Expression that should evaluate to a boolean vector} +} +\details{ + The original help page for these functions is often + available at \code{help("oldName-deprecated")} (note the quotes). + + \code{assert} is a deprecated synonym for \code{\link[base]{stopifnot}}. +} +\seealso{ + \code{\link{Deprecated}}, \code{\link{gtools-defunct}} +} +\keyword{misc} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2008-05-22 16:22:58
|
Revision: 1276 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1276&view=rev Author: warnes Date: 2008-05-22 09:15:21 -0700 (Thu, 22 May 2008) Log Message: ----------- Add checkRVersion to NAMESPACE, and increment version in DESCRIPTION. Modified Paths: -------------- trunk/gtools/DESCRIPTION trunk/gtools/NAMESPACE Modified: trunk/gtools/DESCRIPTION =================================================================== --- trunk/gtools/DESCRIPTION 2008-05-22 16:14:17 UTC (rev 1275) +++ trunk/gtools/DESCRIPTION 2008-05-22 16:15:21 UTC (rev 1276) @@ -1,7 +1,8 @@ Package: gtools Title: Various R programming tools Description: Various R programming tools -Version: 2.4.0 +Version: 2.5.0 +Date: 2008-05-22 Author: Gregory R. Warnes. Includes R source code and/or documentation contributed by Ben Bolker and Thomas Lumley Maintainer: Gregory R. Warnes <wa...@bs...> Modified: trunk/gtools/NAMESPACE =================================================================== --- trunk/gtools/NAMESPACE 2008-05-22 16:14:17 UTC (rev 1275) +++ trunk/gtools/NAMESPACE 2008-05-22 16:15:21 UTC (rev 1276) @@ -6,6 +6,7 @@ assert, binsearch, capture, + checkRVersion, combinations, ddirichlet, defmacro, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |