Skip to content

Instantly share code, notes, and snippets.

@ciela
Last active August 29, 2015 14:04
Show Gist options
  • Save ciela/0027c9cdabc809e0d6c7 to your computer and use it in GitHub Desktop.
Save ciela/0027c9cdabc809e0d6c7 to your computer and use it in GitHub Desktop.
度数分布的なCSVファイルからヒストグラム表示用のベクトルを取得する
freq.vec <- function(csv, xs = 0, xe = 0) {
d <- read.csv(csv)
vars <- d[[1]]
# if default, apply min and max of vars
xs <- ifelse(xs == 0, min(vars), xs)
xe <- ifelse(xe == 0, max(vars), xe)
d.ext <- d[vars >= xs & vars <= xe, ]
rep(d.ext[[1]], d.ext[[2]])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment