Re: [R] rowVars
I've written a rowVars function, but I don't think it throws the error you mention. You're welcome to use it if you like. rowVars <- function(x, na.rm=FALSE, dims=1, unbiased=TRUE, SumSquares=FALSE, twopass=FALSE) { if (SumSquares) return(rowSums(x^2, na.rm, dims)) N <- rowSums(!is.na(x), FALSE, dims) Nm1 <- if (unbiased) N-1 else N if (twopass) {x <- if (dims==0) x - mean(x, na.rm=na.rm) else sweep(x, 1:dims, rowMeans(x,na.rm,dims))} (rowSums(x^2, na.rm, dims) - rowSums(x, na.rm, dims)^2/N) / Nm1 } -- David Brahm ([EMAIL PROTECTED]) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of r user Sent: Friday, March 31, 2006 1:40 PM To: rhelp Subject: [R] rowVars I am using the R 2.2.1 in a Windows XP environment. I have a dataframe with 12 columns and 1,000 rows. (Some of the rows have 1 or fewer values.) I am trying to use rowVars to calculate the variance of each row. I am getting the following message: "Error in na.remove.default(x) : length of 'dimnames' [1] not equal to array extent" Is there a good work-around? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] rowVars
r user wrote: > I am using the R 2.2.1 in a Windows XP environment. > > I have a dataframe with 12 columns and 1,000 rows. > (Some of the rows have 1 or fewer values.) fewer than 1? So you mean 0? Well, the commonly used estimator for the variance is defined for n>=2 elements only! > I am trying to use rowVars to calculate the variance > of each row. I don't know a function rowVars in R-2.2.1 - and cannot find it ... > I am getting the following message: > “Error in na.remove.default(x) : length of 'dimnames' > [1] not equal to array extent” Hard to tell without knowing what you actually did. Uwe Ligges > > Is there a good work-around? > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] rowVars
I am using the R 2.2.1 in a Windows XP environment. I have a dataframe with 12 columns and 1,000 rows. (Some of the rows have 1 or fewer values.) I am trying to use rowVars to calculate the variance of each row. I am getting the following message: Error in na.remove.default(x) : length of 'dimnames' [1] not equal to array extent Is there a good work-around? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html