aboutsummaryrefslogtreecommitdiff
path: root/util.R
blob: 3f1a9b87f987f9c9e235e3f8a6b4d76867511b76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# util.R
#
# Assorted utilities.

# Creates a directory at given path, optionally logging the action.
# If it already exists, the directory is not created.
dir.create.safe <- function(path, log=T) {
  if (!dir.exists(path)) {
    if (log) {
      loginfo("Creating directory: %s", path)
    }

    dir.create(path)
  }
}

# Confidence interval stat summary
ci.fun <- function(d) {
  test <- t.test(d)
  ci <- test$conf.int
  m <- as.double(test$estimate)

  data.frame(ymin=ci[1], ymax=ci[2], y=m)
}