If possible I'd like to produce a function that applies a formula to a column 
in a matrix (essentially calculating the mse) and then inserts it between 
values of a an array ...

confusing I know, here is an example of what I'm trying to accomplish:

## create a matrix
(a <- matrix(c(3,6,4,8,5,9,12,15),nrow=4))
## get the mean of all columns
(b <- apply(a,2,mean))
## calculate the mse of column 1
(c <- (sd(a[,1])/sqrt(length(a[,1]))))
## calculate the mse of column 2
(d <- (sd(a[,2])/sqrt(length(a[,2]))))
## now create a new vector with each mean value and its corresponding
## mse right beside it
(e <- c(b[1],c,b[2],d))

Would anyone have any suggestions how to accomplish this using an apply 
statement?

Thanks a bunch,

J
===============================
Dr. Jim Maas
University of East Anglia

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to