(source: http://nvie.com/posts/a-successful-git-branching-model/)
git checkout -b develop
git remote add origin git push origin develop git pull origin develop
library(digest) | |
test <- c("hobe", "jmjj", 1) | |
digest(test, algo = "md5") | |
digest(test, algo = "sha1") | |
digest(test, algo = "crc32") # not collision proof | |
digest(test, algo = "sha256") | |
digest(test, algo = "sha512") |
# install.packages("rjson") | |
library("rjson") | |
json_file <- "json_file.json" | |
json_data <- fromJSON(paste(readLines(json_file), collapse="")) | |
# additional if needed | |
library(plyr) | |
json_data <- lapply(json_data, as.data.frame) | |
json_data <- do.call(rbind.fill, json_data) |
### string matching | |
### metric to find the similarity between two strings | |
### some context in: | |
### http://en.wikipedia.org/wiki/String_metric | |
### testing levenshtein metric | |
library(RecordLinkage) |
#' best package to read excel files is gdata | |
#' which works with both .xls and .xlsx | |
#' windows: follow instructions here: | |
#' http://cran.r-project.org/web/packages/gdata/INSTALL | |
library(gdata) | |
xlsx_file <- "myfile.xls" | |
sheet1 <- read.xls(xlsx_file, | |
sheet = "Sheet1", | |
stringsAsFactors = FALSE, |
# remove non-ascii characters | |
df$text <- gsub("[^\x20-\x7E]", "", df$text) |
(source: http://nvie.com/posts/a-successful-git-branching-model/)
git checkout -b develop
git remote add origin git push origin develop git pull origin develop
# tricks with regular expressions #### | |
# insert character after a given pattern: use \\1 | |
sub("([[:digit:]]{4})", "\\15", "12346789") |
df$g <- factor(df$g, levels = letters[4:1]) |
library(R2HTML) | |
# setup a temporaty file to store the code | |
fileName <- 'temp.html' | |
.HTML.file = file.path(getwd(), fileName) | |
# make a title | |
HTML(as.title("Title of my report"), append = FALSE) | |
# add space | |
HTMLhr() |
# looping through vector #### | |
library(inline) | |
sign <- signature(x="numeric", n="integer", d="numeric") | |
code <- " | |
for (int i=1; i < *n; i++) { | |
x[i] = x[i-1]*d[0] + x[i]; | |
}" | |
c_fn <- cfunction(sign, |