Re: [R] column means dropping column minimum

2015-12-08 Thread David L Carlson
ect: Re: [R] column means dropping column minimum First, your code has flaws in the assignment of NA and in passing na.rm=TRUE to colMeans(). It should be: test2 <- test for (i in 1:ncol(test)) { test2[which.min(test[,i]),i]=NA} print(test2) samp1 samp2 samp3 16060NA 250

Re: [R] column means dropping column minimum

2015-12-08 Thread Giorgio Garziano
First, your code has flaws in the assignment of NA and in passing na.rm=TRUE to colMeans(). It should be: test2 <- test for (i in 1:ncol(test)) { test2[which.min(test[,i]),i]=NA} print(test2) samp1 samp2 samp3 16060NA 2506065 3NA9065 490NA90

Re: [R] column means dropping column minimum

2015-12-08 Thread phgrosjean
There is a bug in your code: it is not > for (i in 1:ncol(test)) { test2[which.min(test[,i]),i]==NA} but for (i in 1:ncos(test)) { test2[which.min(test[, i]), i] <- NA } Otherwise, a solution would be to create your own function to compute the mean of a vector without the smallest value: me

[R] column means dropping column minimum

2015-12-08 Thread Evan Cooch
Suppose I have something like the following dataframe: samp1 <- c(60,50,20,90) samp2 <- c(60,60,90,58) samp3 <- c(25,65,65,90) test <- data.frame(samp1,samp2,samp3) I want to calculate column means. Easy enough, if I want to use all the data within each column: print(colMeans(test),na.rm =