Re: [Rd] row names of 'rowsum()'
> 'rowsum()' seems to add row names to the resulting matrix, corresponding to > the respective 'group' values. This is very handy, but it is not documented. > Should the documentation mention it so it could be relied upon as part of API? If you're referring to base::rowSums, the 'value' section of the help page says " A numeric or complex array of suitable size, or a vector if the result is one-dimensional. For the first four functions the 'dimnames' (or 'names' for a vector result) are taken from the original array. " S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] row names of 'rowsum()'
I am referring to base::rowsum(), not rowSums(). For some reason I cannot access it's help on my computer but the online documentation (R-devel version) states: Value A matrix or data frame containing the sums. There will be one row per unique value of group Period. Above, the argument 'reorder' is mentioned which orders rows to 'agree with tapply'. Cheers, Ott On Mon, Sep 19, 2016 at 8:41 AM, S Ellison wrote: > > 'rowsum()' seems to add row names to the resulting matrix, corresponding > to > > the respective 'group' values. This is very handy, but it is not > documented. > > Should the documentation mention it so it could be relied upon as part > of API? > > If you're referring to base::rowSums, the 'value' section of the help page > says > " A numeric or complex array of suitable size, or a vector if the > result is one-dimensional. For the first four functions the > 'dimnames' (or 'names' for a vector result) are taken from the > original array. " > > S Ellison > > > *** > This email and any attachments are confidential. Any u...{{dropped:23}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Subsetting issue in model.frame with na.omit
Running R version 3.3.1 (2016-06-21) Bug in Your Hair I have discovered an issue with model.frame() with regard to its implementation of the na.action argument. This impacts the gam package. We are expecting the last thing to happen in model.frame() is that it runs na.action on the frame it has produced. In the example below, we use "na.action=na.omit", which calls for subsetting out rows of the frame. However, when it does this, it does not see that there is a [.smooth method for the two columns, which are of S3 class "smooth". So it does do the subsetting, but does not use the subset methods. In my example, this is evidenced by the attribute element $NAs of (each) of the components still being present. When instead, I use "na.action=na.pass" in the call to model.frame, and then filter the resulting frame through na.omit(), it does the right thing. The $NAs component has disappeared, which is what should have happened here. set.seed(101) n=30 x=matrix(runif(n*2),n,2) x[sample(1:20,6,replace=FALSE)]=NA dx=data.frame(x) library(gam) ###Compare m=model.frame(~s(X1,df=4)+s(X2,df=4),data=dx,na.action=na.omit) attributes(m[[1]]) ###with m=model.frame(~s(X1,df=4)+s(X2,df=4),data=dx,na.action=na.pass) m=na.omit(m) attributes(m[[1]]) -- Trevor Hastie has...@stanford.edu Professor, Department of Statistics, Stanford University Phone: (650) 725-2231 Fax: (650) 725-8977 URL: http://www.stanford.edu/~hastie address: room 104, Department of Statistics, Sequoia Hall 390 Serra Mall, Stanford University, CA 94305-4065 -- __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel