Skip to content

Commit

Permalink
Merge pull request jtleek#75 from rdpeng/master
Browse files Browse the repository at this point in the history
Coding standards lecture
  • Loading branch information
jtleek committed Jan 20, 2014
2 parents 74460b8 + a0b69c0 commit a99b35a
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions 02_RProgramming/CodingStandard/indenting.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
cc <- function(expr, cachedir = ".cache", srcfile = NULL, ...) {
if(!identical(globalenv(), parent.frame()))
stop("'cc' must be called from the global environment")
subexpr <- substitute(expr)
exprtext <- deparse(subexpr, width.cutoff = 60)
if(is.null(srcfile))
srcfile <- file.path(tempdir(), hash(exprtext))
writeLines(exprtext, srcfile)
cacher(srcfile, cachedir, ...)
if(!identical(globalenv(), parent.frame()))
stop("'cc' must be called from the global environment")
subexpr <- substitute(expr)
exprtext <- deparse(subexpr, width.cutoff = 60)

if(is.null(srcfile))
srcfile <- file.path(tempdir(), hash(exprtext))
writeLines(exprtext, srcfile)
cacher(srcfile, cachedir, ...)
}

createLogFile <- function(cachedir, logfile, srcfile) {
if(is.null(logfile)) {
logfile <- file.path(logdir(cachedir),
paste(basename(srcfile), "log", sep="."))
file.create(logfile)
}
else if(is.na(logfile))
logfile <- stderr()
else
file.create(logfile)
setConfig("logfile", logfile)
if(is.null(logfile)) {
logfile <- file.path(logdir(cachedir),
paste(basename(srcfile), "log", sep="."))
file.create(logfile)
}
else if(is.na(logfile))
logfile <- stderr()
else
file.create(logfile)
setConfig("logfile", logfile)
}

identicalFiles <- function(x, y) {
## Are the contents of the two files the same?
checksum <- c(hashFile(x), hashFile(y))
identical(checksum[1], checksum[2])
## Are the contents of the two files the same?
checksum <- c(hashFile(x), hashFile(y))
identical(checksum[1], checksum[2])
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 02_RProgramming/lectures/CodingStandard.pdf
Binary file not shown.

0 comments on commit a99b35a

Please sign in to comment.