File: std.error.R

package info (click to toggle)
r-cran-plotrix 3.2-6-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,136 kB
  • sloc: makefile: 3
file content (19 lines) | stat: -rwxr-xr-x 378 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
std.error<-function(x,na.rm) {
 vn<-function(x) return(sum(!is.na(x)))
 dimx<-dim(x)
 if(is.null(dimx)) {
  stderr<-sd(x,na.rm=TRUE)
  vnx<-vn(x)
 }
 else {
  if(is.data.frame(x)) {
   vnx<-unlist(sapply(x,vn))
   stderr<-unlist(sapply(x,sd,na.rm=TRUE))
  }
  else {
   vnx<-unlist(apply(x,2,vn))
   stderr<-unlist(apply(x,2,sd,na.rm=TRUE))
  }
 }
 return(stderr/sqrt(vnx))  
}