search for: colmeans

Displaying 20 results from an estimated 325 matches for "colmeans".

2008 Mar 16
1
stats/debugging question hotelling t-sq
...ehs/core/microarrays/docs/heinloth.txt",1)) x = t(x) #now rows are subjects, cols are genes x = x[order(rownames(x)),] #order by treatment group oxygen, ultra-violet, gamma radiation y = x[26:45,1:10] x = x[2:25,1:10] p = ncol(x); p nx = nrow(x); nx ny = nrow(y); ny n = nx+ny; n # (t(x)-colMeans(x)) %*% t(t(x)-colMeans(x)) T2 = nx*ny/n * t(colMeans(x)-colMeans(y)) %*% solve( ( (nx-1)*cov(x)+(ny-1)*cov(y) )/( n-2 ) ) %*% (colMeans(x)-colMeans(y)); T2 library(ICSNP) HotellingsT2(y,x) http://en.wikipedia.org/wiki/Hotelling's_T-square_distribution http://finzi.psych.upenn.edu/R/Rhe...
2005 Apr 01
2
Error in colMeans ... what's wrong with my data?
Having searched and searched I still haven't found what's the problem with my data (I've attached the relevant file). Every time I tried to use the CANCOR-Function I got error messages. So I turned to check my two sets of variables separately by using the "colMeans"-Function. With one set no problem .. but with the other. My input : > struktur <- read.delim("struktur.csv", header=TRUE, sep = ";") >colMeans(struktur) And the resulting error: Error in colMeans(x, n, prod(dn), na.rm) : `x' must be numeric Can...
2008 Mar 27
2
colMeans in a data.frame with numeric and character data
Hi all, I would like to know if it is posible by, someway, to get colMeans from a data.frame with numeric as well as character data, dispersed all over the object. Note that I would like to get colMeans neglecting character data. I am really in need of some function proceeding in that way… All the best Diogo André Alagador [[alternative HTML version deleted]]
2023 Apr 21
1
Generalised piping into operators
...ichael Milton wrote: > I just checked out R-devel and noticed that the new "pipe extractor" > capability coming in 4.3 only works for the 4 extractor operators, but no > other standard operators like +, *, %*% etc, meaning that e.g. mtcars |> > as.matrix() |> _ + 1 |> colMeans() is a syntax error. In addition, we are > still subject to the restriction that the functions on the RHS of a pipe > can't have special names, so mtcars |> as.matrix() |> `+`(1) |> colMeans() is > also a syntax error. > > Either option would be great, as I find it much...
2007 Sep 04
2
Howto sort dataframe columns by colMeans
...67 00:10 80 27 84 desired output: time met-c met-a met-b 00:00 99 42 18 00:05 67 88 16 00:10 84 80 27 Thanks, -Lynn -- View this message in context: http://www.nabble.com/Howto-sort-dataframe-columns-by-colMeans-tf4380044.html#a12485729 Sent from the R help mailing list archive at Nabble.com.
2012 Dec 24
2
colmeans not working
...2.33044953 1.0423625 2.7687266 0.2904245 0.70155274 2.4158326 1.2315324 1.4287387 1.5701019 $WW 2008 2009 20101 1.4737028 2.314878 2.6726612 1.6700918 2.609722 2.1124213 3.2387775 7.305766 6.9395364 6.7063592 18.745256 13.278218 afterwards when i applied the "colMeans" command i was not able to calculate the mean as i got the following error >'x' must be an array of at least two dimensions i cant spot the mistake in the last 5 hours. you help is neededthanks in advance eliza -------------- next part -------------- An embedded and cha...
2005 Jan 11
1
Please use colMeans()! was: Re: Calculate Mean of Column Vectors?
...out (and I think it was in S Poetry) the statement was made that vectorisation befuddles some beginners. So learning how to use this command, on a nice easy topic such as summing or averaging does have some merit. I have to admit using colSums a lot, but I don't think I have ever thought to use colMeans. As an aside; does anyone have a list of optimised functions. That is functions like this one whose main benefit is speed (I think) I guess many of us feel that we are constantly using hammers to crack the nuts, but we still don't really know what's in the toolbox. Tom > -----Origina...
2023 Apr 21
1
Generalised piping into operators
I just checked out R-devel and noticed that the new "pipe extractor" capability coming in 4.3 only works for the 4 extractor operators, but no other standard operators like +, *, %*% etc, meaning that e.g. mtcars |> as.matrix() |> _ + 1 |> colMeans() is a syntax error. In addition, we are still subject to the restriction that the functions on the RHS of a pipe can't have special names, so mtcars |> as.matrix() |> `+`(1) |> colMeans() is also a syntax error. Either option would be great, as I find it much cleaner to coordinate a...
2013 Jan 02
4
list of matrices
dear useRs, i have a list containing 16 matrices. i want to calculate the column mean of each of them. i tried >sr <- lapply(s,function(x) colMeans(x, na.rm=TRUE)) but i am getting the following error >Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric can it be done in any other way? and why i am getting this error?? thanks in advance.. elisa [[alternative HTML version deleted]]
2003 May 08
3
Avoiding loops to spare time and memory
...fficient) and can someone point me to a possible solution? (It would be great if hours could be reduced to seconds :-). # --------------------------------------------- RanEigen=function(items=x,cases=y,sample=z) { X=matrix(rnorm(cases*items),nrow=cases,byrow=F) S=crossprod(X-rep(1,cases) %*% t(colMeans(X))) EV=eigen((1/sqrt(diag(S))*diag(items))%*%S%*%(1/sqrt(diag(S))*diag(items)),only.values=T)$values for (i in 2:sample) { X=matrix(rnorm(cases*items),nrow=cases,byrow=F) S=crossprod(X-rep(1,cases) %*% t(colMeans(X))) EV=rbind(EV,eigen((1/sqrt(diag(S))*diag(items))%*%S%*%(1/sqrt(diag(S)...
2010 Jun 01
2
Problem using apply
Hello , I can not get apply function to do what I want when doing stuff on rows. Let's say I want to divide the rows of matrix by their mean, the below show you get the same result weather you use 1 or 2, i.e. same result for columns than for means..:( Thanks a lot for the help, m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 ) divideByMean = function( v ){ return(
2011 Mar 28
0
Bootstrapping the colMeans statistic
I have a fair bit of experience with S-Plus and have been asked to port some of my S-Plus bootstrapping functions to R, to which I am relatively new, Needless to say, I've run into some problems. In particular, I need to perform bootstrap resampling of the colMeans function using a moving blocks bootstrap, where the blocks are row indices. It's easy to build a function that allows me to perform a bootstrap on colMeans, but I'm flummoxed at the moving blocks bootstrap step. I could simply hack together a function that, when given block bootstrap i...
2007 Dec 08
2
NAMESPACE choices for exporting S4 methods
We are building a package, and want to create S4 methods for both head and mean for our own BigMatrix class. Following the recommendation in "Writing R Extensions" we use exportMethods instead of export in NAMESPACE (this is described as being "clearer"). This works for head, but not for mean. Obviously we importFrom(utils, head), but don't need to do this for mean,
2023 Apr 21
1
Generalised piping into operators
...> > I just checked out R-devel and noticed that the new "pipe extractor" > > capability coming in 4.3 only works for the 4 extractor operators, but no > > other standard operators like +, *, %*% etc, meaning that e.g. mtcars |> > > as.matrix() |> _ + 1 |> colMeans() is a syntax error. In addition, we are > > still subject to the restriction that the functions on the RHS of a pipe > > can't have special names, so mtcars |> as.matrix() |> `+`(1) |> > colMeans() is > > also a syntax error. > > > > Either option woul...
2010 Aug 11
2
Sweeping a zoo series
Given a long zoo matrix, the goal is to "sweep" out a statistic from the entire length of the sequences. longzoomatrix<-zoo(matrix(rnorm(720),ncol=6),as.yearmon(outer(1900,seq(0,length=120)/12,"+"))) cnames<-c(12345,23456,34567,45678,56789,67890) colnames(longzoomatrix)<-cnames longzoomatrix[1:24,] 12345 23456 34567 45678
2002 Mar 17
5
compute variance of every column in a matrix without a loop
Is it possible to compute the variance of every column in a matrix without a loop? -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
2009 Aug 25
2
Clarifications please.
...int main (int argc, char** argv) { SEXP e,val; int errorOccurred; Rf_initEmbeddedR(argc, argv); // library("fPortfolio") PROTECT(e = lang2(install("library"), mkString("fPortfolio"))); R_tryEval(e, R_GlobalEnv, NULL); UNPROTECT(1); // colMeans(SWX.RET) PROTECT(e = lang2(install("colMeans"), install("SWX.RET"))); val = (R_tryEval(e, NULL, &errorOccurred)); Rf_PrintValue(val); return 0; } When I tried : >mean(SWX.RET) in the R prompt I got the following output: SBI SPI...
2012 Aug 22
3
Barplot with Secondary axis
...I also tried following code for plotting the line point exactly at the center of two bars: x = c("a","b","c","d") y= cbind(c(50,40,30,20),c(40,30,20,10)) y2 = c(0.80,0.65,0.75,0.50) barplot(t(y),beside = TRUE) a = barplot(t(y),beside = TRUE) par(new=T) plot(colMeans(a),y2,type="l",col="black",lwd= 1,lty=1,xaxt="n",yaxt="n",xlab="",ylab="") points(colMeans(a),y2,pch=20) Please help me in plotting this graph -- View this message in context: http://r.789695.n4.nabble.com/Barplot-with-Secondary-axis-t...
2009 Dec 16
2
Flexclust barchart issue when mcol=NULL (PR#14150)
...ows the text message "Error using packet n replacement has length zero." where n is the panel number. > data(iris) > cl <- cclust(iris[,-5], k=3) > barplot(cl, mcol=NULL) #works fine > barchart(cl, mcol=NULL) # oops FWIW, as the data of the clusters is scaled showing the colMeans for the centers is misleading. The global mean of each column is 0, not the colMean of the centers.
2014 Aug 21
1
Inconsistent handling of data frames in min(), max(), and mean()
...nconsistency recently came to my attention: > df <- data.frame(A = 1:10, B = rnorm(10)) > min(df) [1] -1.768958 > max(df) [1] 10 > mean(df) [1] NA Warning message: In mean.default(df) : argument is not numeric or logical: returning NA I recall the times where `mean(df)` would give `colMeans(df)` and this behaviour was deemed inconsistent. It seems though that the change has removed one inconsistency and replaced it with another. Am I missing good reasons why there couldn't be a `mean.data.frame()` method which worked like `max()` etc when given a data frame? Namely that they retu...