[Rd] interesting connection / finalizer bug?
This setOldClass(c("file", "connection")) .A <- setRefClass("A", fields=list(con="connection"), methods=list( finalize = function() { if (isOpen(con)) close(con) })) f <- tempdir() a <- .A$new(con=file(f, "rb")) close(a$con) a <- .A$new(con=file(f, "rb")) bin <- readBin(a$con, raw(), as.integer(1e8)) crashes (hangs, usually) at the last line, with valgrind saying ==14875== Invalid read of size 8 ==14875==at 0x4EB23DA: do_readbin (connections.c:3678) ==14875==by 0x4F795E4: do_internal (names.c:1236) ==14875==by 0x4F15F63: Rf_eval (eval.c:471) ==14875==by 0x4F18BA7: do_begin (eval.c:1422) ==14875==by 0x4F15F63: Rf_eval (eval.c:471) ==14875==by 0x4F16F0C: Rf_applyClosure (eval.c:840) ==14875==by 0x4F16276: Rf_eval (eval.c:515) ==14875==by 0x4F19939: do_set (eval.c:1726) ==14875==by 0x4F15F63: Rf_eval (eval.c:471) ==14875==by 0x4F5EF6C: Rf_ReplIteration (main.c:256) ==14875==by 0x4F5F159: R_ReplConsole (main.c:305) ==14875==by 0x4F607B8: run_Rmainloop (main.c:986) ==14875== Address 0x907f1d8 is 136 bytes inside a block of size 448 free'd ==14875==at 0x4C25F7B: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==14875==by 0x4EB0282: con_destroy (connections.c:3086) ==14875==by 0x4EB03B3: do_close (connections.c:3105) ==14875==by 0x4F795E4: do_internal (names.c:1236) ==14875==by 0x4F15F63: Rf_eval (eval.c:471) ==14875==by 0x4F19D7F: Rf_evalList (eval.c:1840) == A little more revealing, with two surprises noted, is > f <- tempdir() > a <- .A$new(con=file(f, "rb")) > close(a$con) > a <- .A$new(con=file(f, "rb")) > gc() ## run finalizer -- should complain about invalid connection! used (Mb) gc trigger (Mb) max used (Mb) Ncells 205579 11.0 407500 21.8 35 18.7 Vcells 162784 1.3 786432 6.0 558828 4.3 > bin <- readBin(a$con, raw(), as.integer(1e8)) ## a$con should be ok! Error in readBin(a$con, raw(), as.integer(1e+08)) : invalid connection Presumably the example without the explicit garbage collection results from a garbage collection triggered after the connection has been tested for validity. This is not a finalizer bug, as the following elicits the same behavior invisible(gcinfo(TRUE)) f <- tempdir() e <- new.env() reg.finalizer(e, function(e) tryCatch({ if (isOpen(e$con)) close(e$con) })) e$con <- file(f, "rb") close(e$con) e <- new.env() e$con <- file(f, "rb") bin <- readBin(e$con, raw(), as.integer(1e8)) > sessionInfo() R Under development (unstable) (2012-01-04 r58051) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] seq_along and rep_along
Hi all, A couple of ideas for improving seq_along: * It would be really useful to have a second argument dim: seq_along(mtcars, 1) seq_along(mtcars, 2) # equivalent to seq_len(dim(mtcars)[1]) seq_len(dim(mtcars)[2]) I often find myself wanting to iterate over the rows or column of a data frame, and there isn't a particularly nice idiom if you want to avoid problems with zeros - you have to use seq_len(nrow(df)) etc * To me, it would seem be very natural to have a rep_along function: rep_along <- function(x, y) rep(x, length.out = length(y)) possibly with more checking for the case where the lengths aren't integer multiples. I'd be happy to submit proposed implementations/documentation if there was interest. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R CMD check WARNING \usage question
I'm trying to update a package and would like to crush a WARNING message for a clean build. I've been struggling with this question and haven't gotten any traction on the web either. I've got a document file (Rd) that contains the following \usage statement: \name{sample.data} \alias{sample.data} \title{CONIFERS forest growth model sample data} \description{ A list object of type \code{sample.data} stores all of the basic information about a \code{\link{data.frame}} object representing a sample of plants.} \usage{ x <- list( plots=data.frame(), plants=data.frame(), age=0, x0=0.0, n.years.projected=0 ) class(x) <- "sample.data" } When I run R CMD check [pkg], I get the following WARNING: * checking Rd \usage sections ... WARNING Assignments in \usage in documentation object 'sample.data': x <- list(plots, plants, age = 0, x0 = 0, n.years.projected = 0) class(x) <- "sample.data" Functions with \usage entries need to have the appropriate \alias entries, and all their arguments documented. The \usage entries must correspond to syntactically valid R code. See the chapter 'Writing R documentation files' in manual 'Writing R Extensions'. * checking Rd contents ... OK I'm not sure if there's a problem with the \alias section or the \usage section or both sections (I'm assuming this is the case). I've read the Chapter 2 of R-ext.pdf plenty and just can't seem to see where I'm blowing it. Respectfully, Jeff. Jeff Hamann, PhD PO Box 1421 Corvallis, Oregon 97339-1421 541-754-2457 jeff.hamann[at]forestinformatics[dot]com jeff.d.hamann[at]gmail[dot]com http://www.forestinformatics.com http://en.wikipedia.org/wiki/Forest_informatics To ensure that your email is processed, include a subject entry in your email. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] delete.response leaves response in attribute dataClasses
Thanks, Bill Counter-arguments at the end On Thu, Jan 5, 2012 at 3:15 PM, William Dunlap wrote: > My feeling that everyone would index dataClasses by name was > wrong. I looked through the packages that used dataClasses > and saw code that would break if the first (response) entry > were omitted. (I didn't check to see if passing the output > of delete.response to these functions would be appropriate.) > E.g., > file: AICcmodavg/R/predictSE.mer.r > ##matrix with info on factors > fact.frame <- attr(attr(orig.frame, "terms"), "dataClasses")[-1] > > ##continue if factors > if(any(fact.frame == "factor")) { > id.factors <- which(fact.frame == "factor") > fact.name <- names(fact.frame)[id.factors] #identify the rows for factors > > Some packages create a dataClass attribute for a model.frame > (not its terms attribute) that does not have any names: > file: caper/R/macrocaic.R > attr(mf, "dataClasses") <- rep("numeric", dim(termFactors)[2]) > .checkMFClasses() does not throw an error for that, but it > doesn't do any real checking either. > > Most users of dataClasses do pass it to .checkMFClasses() to > compare it with newdata and that doesn't care if you have extra > entries in dataClasses. > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > I can't understand what your point is. I agree we can work around the problem, but why should we have to? If you confine yourself to the output of "delete.response" applied to a terms object from a regression, can you point to any package or usage that depends on leaving the response variable in the dataClasses attribute? I can't find one. In R base, these are all the references to delete.response: stats/R/models.R:delete.response <- function (termobj) stats/R/lm.R:Terms <- delete.response(tt) stats/R/lm.R:Terms <- delete.response(tt) stats/R/ppr.R:Terms <- delete.response(object$terms) stats/R/loess.R: as.matrix(model.frame(delete.response(terms(object)), newdata, stats/R/dummy.coef.R:Terms <- delete.response(Terms) I've looked it over carefully and predict.lm (in lm.R) would not be affected by the change I propose. I can't find any usage in loess.R of the dataClasses attribute. Furthermore, I can't see how a person would use the dataClasses attribute at all, after the other markers of the response are eliminated. How is a method to find which variable is the response, after response=0? I'm not disagreeing with you that I can workaround the peculiarity that the response is left in the dataClasses attribute of the output object from delete.response. I'm just saying it is a complication that programmers should not have to put up with, because I think delete.response should delete the response from all attributes of a terms object. pj -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] seq_along and rep_along
On 12-01-06 1:31 PM, Hadley Wickham wrote: Hi all, A couple of ideas for improving seq_along: * It would be really useful to have a second argument dim: seq_along(mtcars, 1) seq_along(mtcars, 2) # equivalent to seq_len(dim(mtcars)[1]) seq_len(dim(mtcars)[2]) I often find myself wanting to iterate over the rows or column of a data frame, and there isn't a particularly nice idiom if you want to avoid problems with zeros - you have to use seq_len(nrow(df)) etc I don't see the benefit of seq_along(mtcars, 1) versus seq_len(nrow(df)) in readability. Duncan Murdoch * To me, it would seem be very natural to have a rep_along function: rep_along<- function(x, y) rep(x, length.out = length(y)) possibly with more checking for the case where the lengths aren't integer multiples. I'd be happy to submit proposed implementations/documentation if there was interest. Hadley __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check WARNING \usage question
I know I should provide a better answer, but I think it's really for a function. For this package, we simply pass a list object about, but have to obfuscate it using a domain familiar nomenclature for the users. So, not a data set, but a function. I think. Here's the file in it's entirety: %% $Id $ \name{sample.data} \alias{sample.data} \title{CONIFERS forest growth model sample data} \description{ A list object of type \code{sample.data} stores all of the basic information about a \code{\link{data.frame}} object representing a sample of plants.} \usage{ x <- list( plots=data.frame(), plants=data.frame(), age=0, x0=0.0, n.years.projected=0 ) class(x) <- "sample.data" } \details{ To create the basic data type used in rconifers, you create a list object with the following elements (order is not important): \describe{ \item{plots}{is a \link{data.frame} with the the same elements as \code{\link{plots.swo}}.} \item{plants}{is a \link{data.frame} with the the same elements as \code{\link{plants.swo}}.} \item{age}{is an integer value that represents the age of the plants, in years.} \item{x0}{is the $x_{0}$ coefficient for the Hann and Wang (1990) mortality model.} \item{n.years.projected}{is the number of years that $x$ has been projected forward in time.} } } \references{ Ritchie, M.W. 2008. User's Guide and Help System for CONIFERS: A Simulator for Young Conifer Plantations Version 4.10. See \url{http://www.fs.fed.us/psw/programs/ecology_of_western_forests/projects/conifers/} } \author{Jeff D. Hamann \email{jeff.ham...@forestinformatics.com},\cr Martin W. Ritchie \email{mritc...@fs.fed.us} } \seealso{\code{\link{plants.smc}}, \code{\link{plots.smc}} \code{\link{plants.swo}}, \code{\link{plots.swo}}, \code{\link{sample.data}}, \code{\link{set.species.map}}, \code{\link{set.variant}}, \code{\link{smc}}, \code{\link{summary.sample.data}}, \code{\link{swo}}, \code{\link{thin}} } \examples{ library( rconifers ) ## Example for SWO variant ## set the variant to the SWO variant and set species map ##set.species.map( set.variant(0) ) set.variant(0) ## grow the data that was originally swo in the smc variant # load and display CONIFERS example plots data( plots.swo ) print( plots.swo ) # load and display CONIFERS example plants data( plants.swo ) print( plants.swo ) # create the sample.data list object sample.swo.3 <- list( plots=plots.swo, plants=plants.swo, age=3, x0=0.0,n.years.projected=0) class(sample.swo.3) <- "sample.data" } \keyword{models} and the WARNING: * checking Rd \usage sections ... WARNING Assignments in \usage in documentation object 'sample.data': x <- list(plots, plants, age = 0, x0 = 0, n.years.projected = 0) class(x) <- "sample.data" Functions with \usage entries need to have the appropriate \alias entries, and all their arguments documented. The \usage entries must correspond to syntactically valid R code. See the chapter 'Writing R documentation files' in manual 'Writing R Extensions'. * checking Rd contents ... OK Respectfully, Jeff. Jeff Hamann, PhD PO Box 1421 Corvallis, Oregon 97339-1421 541-754-2457 jeff.hamann[at]forestinformatics[dot]com jeff.d.hamann[at]gmail[dot]com http://www.forestinformatics.com http://en.wikipedia.org/wiki/Forest_informatics To ensure that your email is processed, include a subject entry in your email. On Jan 6, 2012, at 11:38 AM, Bryan Hanson wrote: > Jeff, quick question: is this a data set or a function you are documenting? > What you say sounds like it's data, but the Rd file reads more like a > function. Or are you trying to document a data format/object which stores > specific data sets? > > Let us know, and I'll bet the answer will appear pretty quickly. Bryan > > *** > Bryan Hanson > Professor of Chemistry & Biochemistry > DePauw University > > On Jan 6, 2012, at 2:11 PM, Jeff Hamann wrote: > >> I'm trying to update a package and would like to crush a WARNING message for >> a clean build. >> >> I've been struggling with this question and haven't gotten any traction on >> the web either. >> >> I've got a document file (Rd) that contains the following \usage statement: >> >> \name{sample.data} >> \alias{sample.data} >> >> \title{CONIFERS forest growth model sample data} >> >> \description{ A list object of type \code{sample.data} stores all of >> the basic information about a \code{\link{data.frame}} object >> representing a sample of plants.} >> >> \usage{ >> x <- list( plots=data.frame(), plants=data.frame(), age=0, x0=0.0, >> n.years.projected=0 ) >> class(x) <- "sample.data" >> } >> >> When I run R CMD check [pkg], I get the following WARNING: >> >> * checking Rd \usage sections ... WARNING >> Assignments in \usage in documentation object 'sample.data': >> x <- li
Re: [Rd] seq_along and rep_along
> I don't see the benefit of seq_along(mtcars, 1) versus seq_len(nrow(df)) in > readability. I like it because: * it reads nicely: I want a sequence along this structure in that direction * it's more consistent: for(i in seq_along(x)) -> for(row in seq_along(mtcars, 1)) * it generalised in a straightforward way to arrays I don't think it's a huge improvement, but it is frustrating when base functionality only works with vectors, not matrices, or arrays. It would be more compelling if (e.g.) t and rev also had dimension arguments. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check WARNING \usage question
Jeff, quick question: is this a data set or a function you are documenting? What you say sounds like it's data, but the Rd file reads more like a function. Or are you trying to document a data format/object which stores specific data sets? Let us know, and I'll bet the answer will appear pretty quickly. Bryan *** Bryan Hanson Professor of Chemistry & Biochemistry DePauw University On Jan 6, 2012, at 2:11 PM, Jeff Hamann wrote: > I'm trying to update a package and would like to crush a WARNING message for > a clean build. > > I've been struggling with this question and haven't gotten any traction on > the web either. > > I've got a document file (Rd) that contains the following \usage statement: > > \name{sample.data} > \alias{sample.data} > > \title{CONIFERS forest growth model sample data} > > \description{ A list object of type \code{sample.data} stores all of > the basic information about a \code{\link{data.frame}} object > representing a sample of plants.} > > \usage{ > x <- list( plots=data.frame(), plants=data.frame(), age=0, x0=0.0, > n.years.projected=0 ) > class(x) <- "sample.data" > } > > When I run R CMD check [pkg], I get the following WARNING: > > * checking Rd \usage sections ... WARNING > Assignments in \usage in documentation object 'sample.data': > x <- list(plots, plants, age = 0, x0 = 0, n.years.projected = 0) > class(x) <- "sample.data" > > Functions with \usage entries need to have the appropriate \alias > entries, and all their arguments documented. > The \usage entries must correspond to syntactically valid R code. > See the chapter 'Writing R documentation files' in manual 'Writing R > Extensions'. > * checking Rd contents ... OK > > I'm not sure if there's a problem with the \alias section or the \usage > section or both sections (I'm assuming this is the case). > > I've read the Chapter 2 of R-ext.pdf plenty and just can't seem to see where > I'm blowing it. > > Respectfully, > Jeff. > > > Jeff Hamann, PhD > PO Box 1421 > Corvallis, Oregon 97339-1421 > 541-754-2457 > jeff.hamann[at]forestinformatics[dot]com > jeff.d.hamann[at]gmail[dot]com > http://www.forestinformatics.com > http://en.wikipedia.org/wiki/Forest_informatics > > To ensure that your email is processed, include a subject entry in your email. > > > > > > [[alternative HTML version deleted]] > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check WARNING \usage question
Jeff, this sounds like a standardized data format, not a function. You are basically telling the user how to put their own data into the correct format. You are not giving them any data (at least not with this file), and you are not giving them a function because there is no function here to do the same thing over and over with different data. If this sounds right, I think the answer is you have to write your own custom Rd file that as far as I know is not really documented per se. However, I have done this exact thing, so I'm appending an example below (from package ChemoSpec). See if this makes sense. Bryan \name{Spectra} \Rdversion{1.1} \title{ Spectra Objects } \alias{Spectra} \description{ In \code{ChemoSpec}, spectral data sets are stored in an S3 class called \code{Spectra}, which contains a variety of information in addition to the spectra themselves. \code{Spectra} objects are created by \code{\link{getManyCsv}} or similar functions (no others currently exist). } \section{Structure}{ The structure of a \code{Spectra} object is a list of 7 elements and an attribute as follows: \tabular{lll}{ \emph{element} \tab \emph{type} \tab \emph{description}\cr $freq \tab num \tab A common frequency (or wavelength) axis for all the spectra.\cr $data \tab num \tab The intensities for the spectra. A matrix of dimension \cr \tab \tab no. samples x no. frequency points.\cr $names \tab chr \tab The sample names for the spectra; length must be no. samples.\cr $groups \tab Factor \tab The group classification of the samples; length must be no. samples.\cr $colors \tab chr \tab The colors for each sample; length must be no. samples. \cr \tab \tab Groups and colors correspond.\cr $sym \tab integer \tab As for \code{colors}, but symbols for plotting (if b/w is desired).\cr $alt.sym \tab chr \tab Lower-case letters as alternate symbols for plotting.\cr $unit \tab chr \tab Two entries, the first giving the x axis unit, the second the y axis unit.\cr $desc \tab chr \tab A character string describing the data set. This appears on plots and therefore \cr \tab \tab should probably be kept to 40 characters or less.\cr - attr \tab chr "Spectra" \tab The S3 class designation.\cr } } \seealso{ \code{\link{sumSpectra}} to summarize a \code{"Spectra"} object. \code{\link{sumGroups}} to summarize group membership of a \code{"Spectra"} object. \code{\link{chkSpectra}} to verify the integrity of a \code{"Spectra"} object. \code{\link{colorSymbol}} for a discussion of color options. } \references{ \url{http://academic.depauw.edu/~hanson/ChemoSpec/ChemoSpec.html} } \author{ Bryan A. Hanson, DePauw University. \email{han...@depauw.edu} } \keyword{ classes } On Jan 6, 2012, at 2:48 PM, Jeff Hamann wrote: > I know I should provide a better answer, but I think it's really for a > function. > > For this package, we simply pass a list object about, but have to obfuscate > it using a domain familiar nomenclature for the users. > > So, not a data set, but a function. I think. > > Here's the file in it's entirety: > > > %%$Id $ > > \name{sample.data} > \alias{sample.data} > > \title{CONIFERS forest growth model sample data} > > \description{ A list object of type \code{sample.data} stores all of > the basic information about a \code{\link{data.frame}} object > representing a sample of plants.} > > \usage{ > x <- list( plots=data.frame(), plants=data.frame(), age=0, x0=0.0, > n.years.projected=0 ) > class(x) <- "sample.data" > } > > \details{ > To create the basic data type used in rconifers, you create a > list object with the following elements (order is not > important): > \describe{ > \item{plots}{is a \link{data.frame} with the the same elements as > \code{\link{plots.swo}}.} > \item{plants}{is a \link{data.frame} with the the same elements as > \code{\link{plants.swo}}.} > \item{age}{is an integer value that represents the age of the plants, > in years.} > \item{x0}{is the $x_{0}$ coefficient for the Hann and Wang (1990) mortality > model.} > \item{n.years.projected}{is the number of years that $x$ has been > projected forward in time.} > } > } > > \references{ > > Ritchie, M.W. 2008. User's Guide and Help System for CONIFERS: A Simulator > for Young Conifer Plantations Version > 4.10. See > \url{http://www.fs.fed.us/psw/programs/ecology_of_western_forests/projects/conifers/} > > } > > \author{Jeff D. Hamann \email{jeff.ham...@forestinformatics.com},\cr >Martin W. Ritchie \email{mritc...@fs.fed.us} } > > \seealso{\code{\link{plants.smc}}, >\code{\link{plots.smc}} >\code{\link{plants.swo}}, >\code{\link{plots.swo}}, >\code{\link{sample.data}}, >\code{\link{set.species.map}}, >\code{\link{set.variant}}, >\code{\link{smc}}, >\code{\link{summary.sample.data}}, >\code{\link{swo}}, >\code{\lin
Re: [Rd] R CMD check WARNING \usage question
On 12-01-06 2:48 PM, Jeff Hamann wrote: I know I should provide a better answer, but I think it's really for a function. For this package, we simply pass a list object about, but have to obfuscate it using a domain familiar nomenclature for the users. So, not a data set, but a function. I think. You are documenting "sample.data", according to the name and alias. But you create an object called "x". There is no object (function or data) called "sample.data". It's the name of an S3 class. Now, there isn't a \docType setting for documenting an S3 class; they are usually documented along with the function that produces them. So the easiest thing to do is probably to create a function (called sample.data, if you like) that produces the object, and document its usage. Alternatively, don't use Rd for your documentation, write a vignette. But that's a lot more work. Or create a prototype sample.data object (which is what your x looks like, being mostly empty), and document it using \docType{data}. Move the code from your \usage section to \examples. Duncan Murdoch Here's the file in it's entirety: %% $Id $ \name{sample.data} \alias{sample.data} \title{CONIFERS forest growth model sample data} \description{ A list object of type \code{sample.data} stores all of the basic information about a \code{\link{data.frame}} object representing a sample of plants.} \usage{ x<- list( plots=data.frame(), plants=data.frame(), age=0, x0=0.0, n.years.projected=0 ) class(x)<- "sample.data" } \details{ To create the basic data type used in rconifers, you create a list object with the following elements (order is not important): \describe{ \item{plots}{is a \link{data.frame} with the the same elements as \code{\link{plots.swo}}.} \item{plants}{is a \link{data.frame} with the the same elements as \code{\link{plants.swo}}.} \item{age}{is an integer value that represents the age of the plants, in years.} \item{x0}{is the $x_{0}$ coefficient for the Hann and Wang (1990) mortality model.} \item{n.years.projected}{is the number of years that $x$ has been projected forward in time.} } } \references{ Ritchie, M.W. 2008. User's Guide and Help System for CONIFERS: A Simulator for Young Conifer Plantations Version 4.10. See \url{http://www.fs.fed.us/psw/programs/ecology_of_western_forests/projects/conifers/} } \author{Jeff D. Hamann \email{jeff.ham...@forestinformatics.com},\cr Martin W. Ritchie \email{mritc...@fs.fed.us} } \seealso{\code{\link{plants.smc}}, \code{\link{plots.smc}} \code{\link{plants.swo}}, \code{\link{plots.swo}}, \code{\link{sample.data}}, \code{\link{set.species.map}}, \code{\link{set.variant}}, \code{\link{smc}}, \code{\link{summary.sample.data}}, \code{\link{swo}}, \code{\link{thin}} } \examples{ library( rconifers ) ## Example for SWO variant ## set the variant to the SWO variant and set species map ##set.species.map( set.variant(0) ) set.variant(0) ## grow the data that was originally swo in the smc variant # load and display CONIFERS example plots data( plots.swo ) print( plots.swo ) # load and display CONIFERS example plants data( plants.swo ) print( plants.swo ) # create the sample.data list object sample.swo.3<- list( plots=plots.swo, plants=plants.swo, age=3, x0=0.0,n.years.projected=0) class(sample.swo.3)<- "sample.data" } \keyword{models} and the WARNING: * checking Rd \usage sections ... WARNING Assignments in \usage in documentation object 'sample.data': x<- list(plots, plants, age = 0, x0 = 0, n.years.projected = 0) class(x)<- "sample.data" Functions with \usage entries need to have the appropriate \alias entries, and all their arguments documented. The \usage entries must correspond to syntactically valid R code. See the chapter 'Writing R documentation files' in manual 'Writing R Extensions'. * checking Rd contents ... OK Respectfully, Jeff. Jeff Hamann, PhD PO Box 1421 Corvallis, Oregon 97339-1421 541-754-2457 jeff.hamann[at]forestinformatics[dot]com jeff.d.hamann[at]gmail[dot]com http://www.forestinformatics.com http://en.wikipedia.org/wiki/Forest_informatics To ensure that your email is processed, include a subject entry in your email. On Jan 6, 2012, at 11:38 AM, Bryan Hanson wrote: Jeff, quick question: is this a data set or a function you are documenting? What you say sounds like it's data, but the Rd file reads more like a function. Or are you trying to document a data format/object which stores specific data sets? Let us know, and I'll bet the answer will appear pretty quickly. Bryan *** Bryan Hanson Professor of Chemistry& Biochemistry DePauw University On Jan 6, 2012, at 2:11 PM, Jeff Hamann wrote: I'm trying to update a package and would like to crush a WARNING message for a clean build. I've b
Re: [Rd] delete.response leaves response in attribute dataClasses
> -Original Message- > From: Paul Johnson [mailto:pauljoh...@gmail.com] > Sent: Friday, January 06, 2012 11:17 AM > To: William Dunlap > Cc: R Devel List > Subject: Re: [Rd] delete.response leaves response in attribute dataClasses > > Thanks, Bill > > Counter-arguments at the end > > On Thu, Jan 5, 2012 at 3:15 PM, William Dunlap wrote: > > My feeling that everyone would index dataClasses by name was > > wrong. I looked through the packages that used dataClasses > > and saw code that would break if the first (response) entry > > were omitted. (I didn't check to see if passing the output > > of delete.response to these functions would be appropriate.) > > E.g., > > file: AICcmodavg/R/predictSE.mer.r > > ##matrix with info on factors > > fact.frame <- attr(attr(orig.frame, "terms"), "dataClasses")[-1] > > > > ##continue if factors > > if(any(fact.frame == "factor")) { > > id.factors <- which(fact.frame == "factor") > > fact.name <- names(fact.frame)[id.factors] #identify the rows for factors > > > > Some packages create a dataClass attribute for a model.frame > > (not its terms attribute) that does not have any names: > > file: caper/R/macrocaic.R > > attr(mf, "dataClasses") <- rep("numeric", dim(termFactors)[2]) > > .checkMFClasses() does not throw an error for that, but it > > doesn't do any real checking either. > > > > Most users of dataClasses do pass it to .checkMFClasses() to > > compare it with newdata and that doesn't care if you have extra > > entries in dataClasses. > > > > Bill Dunlap > > Spotfire, TIBCO Software > > wdunlap tibco.com > > > > I can't understand what your point is. I agree we can work around the > problem, but why should we have to? I guess my point was that it would make sense for delete.response to drop the response element from dataClasses, as it has no use. It was almost certainly an oversight that it wasn't dropped, as most terms objects don't have the dataClasses attribute. Properly written code, which only subscripted dataClasses by name (not by number) would not be affected by the change but improperly written code (e.g., AICcmodavg's predictSE, which assumes the response is in position 1) would be adversely affected in the unlikely case that someone passed it the output of delete.response. I don't know how much you want to cater to "errors" by package writers. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > > If you confine yourself to the output of "delete.response" applied to > a terms object from a regression, can you point to any package or > usage that depends on leaving the response variable in the dataClasses > attribute? I can't find one. In R base, these are all the references > to delete.response: > > stats/R/models.R:delete.response <- function (termobj) > stats/R/lm.R:Terms <- delete.response(tt) > stats/R/lm.R:Terms <- delete.response(tt) > stats/R/ppr.R:Terms <- delete.response(object$terms) > stats/R/loess.R: > as.matrix(model.frame(delete.response(terms(object)), newdata, > stats/R/dummy.coef.R:Terms <- delete.response(Terms) > > I've looked it over carefully and predict.lm (in lm.R) would not be > affected by the change I propose. I can't find any usage in loess.R of > the dataClasses attribute. > > Furthermore, I can't see how a person would use the dataClasses > attribute at all, after the other markers of the response are > eliminated. How is a method to find which variable is the response, > after response=0? > > I'm not disagreeing with you that I can workaround the peculiarity > that the response is left in the dataClasses attribute of the output > object from delete.response. I'm just saying it is a complication > that programmers should not have to put up with, because I think > delete.response should delete the response from all attributes of a > terms object. > > pj > > > -- > Paul E. Johnson > Professor, Political Science > 1541 Lilac Lane, Room 504 > University of Kansas __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] pointers on including SVN revision number in package info?
I'm trying to keep debugging of a development package relatively sane. I see that some packages manage to incorporate what appears to be Subversion (SVN) revision information in the package description; for example, > library(MASS) > sessionInfo()$otherPkgs$MASS$Revision [1] "$Rev: 3016 $" which looks like an auto-generated revision number. On the other hand, the rgl package (for example) appears to manually encode the SVN revision in the package number: > library(rgl) > sessionInfo()$otherPkgs$rgl$Version [1] "0.92.829" I'd love an automatic strategy, if possible, so I can be lazy about updating the DESCRIPTION file every time I commit a change to SVN ... I searched the R extensions manual (and the r-forge manual), but I'm sure I could have missed something ... Or can people suggest other useful strategies for keeping track of which development (micro-)version a random user might be working with? thanks, Ben Bolker __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] rJava System.out / System.err & stacktraces
Hi, Is there any way to initialize rJava so it can print System.out and System.err to console? Also, is there any way to see stack traces? Otherwise we're limited to just seeing: > .jcall(machine, "V", "Build") > .jcheck() Error: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 which doesn't tell me much about the problem nor where the problem occurred in the Java code. If there's no way to do this, I'm just going to have to send every System.out/err statement in my code to a log file which is a very ugly way of doing debugging. Thanks, Adam -- View this message in context: http://r.789695.n4.nabble.com/rJava-System-out-System-err-stacktraces-tp4270712p4270712.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] pointers on including SVN revision number in package info?
On 06/01/2012 20:24, Ben Bolker wrote: I'm trying to keep debugging of a development package relatively sane. I see that some packages manage to incorporate what appears to be Subversion (SVN) revision information in the package description; for example, library(MASS) sessionInfo()$otherPkgs$MASS$Revision [1] "$Rev: 3016 $" which looks like an auto-generated revision number. On the other hand, the rgl package (for example) appears to manually encode the SVN revision in the package number: library(rgl) sessionInfo()$otherPkgs$rgl$Version [1] "0.92.829" I'd love an automatic strategy, if possible, so I can be lazy about updating the DESCRIPTION file every time I commit a change to SVN ... I searched the R extensions manual (and the r-forge manual), but I'm sure I could have missed something ... The Subversion book? The MASS/DESCRIPTION file has gannet% svn proplist DESCRIPTION Properties on 'DESCRIPTION': svn:keywords Note this only tracks the version when DESCRIPTION is changed, not what anything else is updated. But then I change the DESCRIPTION file immediately before release. Or can people suggest other useful strategies for keeping track of which development (micro-)version a random user might be working with? thanks, Ben Bolker __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] pointers on including SVN revision number in package info?
On 6 January 2012 at 20:37, Prof Brian Ripley wrote: | The Subversion book? The MASS/DESCRIPTION file has | | gannet% svn proplist DESCRIPTION | Properties on 'DESCRIPTION': |svn:keywords Yep, I do the same for the $Date$ property in my DESCRIPTION files. Upon commit of the file (eg when incrementing the minor version), the date gets updated automagically. You have to set the Date property, which even has its own sub-menu if you happen to use the psvn mode under the One True Editor (TM). Eg for the most recent Rcpp: Date: $Date: 2011-12-25 14:14:33 -0600 (Sun, 25 Dec 2011) $ and the two $ signs give it away if you know these SVN tricks... | Note this only tracks the version when DESCRIPTION is changed, not what | anything else is updated. But then I change the DESCRIPTION file | immediately before release. Correct. The flipside is that you can also add $Revision$, $URL$, ... to each R source file individually, and they all get their own stamps. I luuuv monotonically increasing SVN revs, but some git fanboy will surely chime in within the hour and tell me that I am off my rocker. ;-) | >Or can people suggest other useful strategies for keeping track of | > which development (micro-)version a random user might be working with? You cannot do something simple Version: 0.2.3.$Revision$ because the $ will stay there, as discussed above. But you can filter. In the littler sources we do this with a helper script (which I include below). That gets us this revision display with an autocreated header file: edd@max:~$ r --version | head -2 r ('littler') version 0.1.5 svn revision 185 as of 2011-09-17 09:35:56 edd@max:~$ You can use the other magic keywords listed in section "Keyword Substitution" in Chapter 3: "Advanced Topics" of the SVN book which Brian Ripley already pointed to. Dirk -- "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] pointers on including SVN revision number in package info?
On 12-01-06 3:24 PM, Ben Bolker wrote: I'm trying to keep debugging of a development package relatively sane. I see that some packages manage to incorporate what appears to be Subversion (SVN) revision information in the package description; for example, library(MASS) sessionInfo()$otherPkgs$MASS$Revision [1] "$Rev: 3016 $" which looks like an auto-generated revision number. On the other hand, the rgl package (for example) appears to manually encode the SVN revision in the package number: library(rgl) sessionInfo()$otherPkgs$rgl$Version [1] "0.92.829" Yes, those are done manually. I'd love an automatic strategy, if possible, so I can be lazy about updating the DESCRIPTION file every time I commit a change to SVN ... I searched the R extensions manual (and the r-forge manual), but I'm sure I could have missed something ... I'd like one that produced an R version number directly, but I think Dirk's script is the only way to do it, and I forget how to use such scripts five minutes after I write them. Or can people suggest other useful strategies for keeping track of which development (micro-)version a random user might be working with? R-forge sometimes gets out of sync in what it displays as the revision, the Version, and what it actually offers as the "Package source" (let alone binaries), so I find putting the revision into the version number very helpful. But I often forget to do it... Duncan Murdoch thanks, Ben Bolker __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] pointers on including SVN revision number in package info?
On 6 January 2012 at 16:45, Duncan Murdoch wrote: | I'd like one that produced an R version number directly, but I think | Dirk's script is the only way to do it, and I forget how to use such | scripts five minutes after I write them. And I of course forgot to include the little script once written for littler; now below. For Rcpp and RInside, I wrote little ad-hoc release helper scripts to also run doxygen, copy vignettes and tarballs to webfolders etc pp. If you do that, you have a hook -- but then you'd have to run this once pre-commit / build. | R-forge sometimes gets out of sync in what it displays as the revision, | the Version, and what it actually offers as the "Package source" (let | alone binaries), so I find putting the revision into the version number | very helpful. But I often forget to do it... Scripts can help. Somewhat. Dirk PS The ad-hoc script 'bootstrap' from littler is below. #!/bin/bash -e call_svnversion() { svnrevision=`LC_ALL=C svn info | awk '/^Revision:/ {print $2}'` svndate=`LC_ALL=C svn info | awk '/^Last Changed Date:/ {print $4,$5}'` now=`date` if [ "$svnrevision" != "" ]; then if [ "$svndate" != "" ]; then cat < svnversion.h // Do not edit! This file was autogenerated // by $0 // on $now // // svnrevision and svndate are as reported by svn at that point in time, // compiledate and compiletime are being filled gcc at compilation #include static const char* svnrevision = "$svnrevision"; static const char* svndate = "$svndate"; static const char* compiletime = __TIME__; static const char* compiledate = __DATE__; EOF fi fi } if [ "$#" -ge 0 ]; then if [ "$1" = "--svnversion" ]; then # added hoops: make sure we only call this when we have a # svn binary in the path ... so that this does not get called # on machines that do not have svn set +e svnprog=`type -p svn` set -e if [ "${svnprog}" != "" ]; then call_svnversion fi exit fi fi test -f svnversion.h || call_svnversion aclocal autoheader automake autoconf ./configure make -- "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel