require(httr)
## Loading required package: httr
[...] | |
```{r, include=FALSE} | |
RMDtoRpres <- function(fname){ | |
require(stringr) | |
text <- readLines(fname, encoding="UTF-8") | |
text <- paste(text, collapse="\n") | |
author <- str_replace_all(str_extract(text,'author: ".*?\n'),'["\n]',"") | |
date <- str_replace_all(str_extract(text,"date: '.*?\n"),'["\n]',"") | |
title <- str_replace(str_replace_all(str_extract(text,'title: ".*?\n'),'["\n]',""),"title: ","") |
#!/path/2/Rscript | |
# License: CC0 (just be nice and point others to where you got this) Author: | |
# Robert M Flight <[email protected]>, github.com/rmflight | |
# | |
# This is a post-commit hook that after a successful commit subsequently | |
# increments the package version in DESCRIPTION and commits that. Analogous to | |
# the pre-commit at https://gist.github.com/rmflight/8863882, but useful if you | |
# only have good reasons for not doing it on the pre-commit. | |
# |
require(httr)
## Loading required package: httr
https://twitter.com/fgilardi/status/573873339682418689/photo/1
to_char_bars <- function(input){
### Description ### | |
# author: peter meissner (https://github.com/petermeissner | http://pmeissner.com) | |
# purpose: Browsing data frames in R is annoying. | |
# The function provided here allows to browse data frames within the | |
# browser using HTML and some JavaScript. | |
#' function for making html table | |
#' @param x data.frame or matrix to be transformed |
#' function for getting mode source: http://stackoverflow.com/a/8189441/1144966 | |
#' @param x vector for which the mode should be returned | |
modus <- function(x) { | |
ux <- unique(x) | |
ux[which.max(tabulate(match(x, ux)))] | |
} |
# function that loads packages | |
package <- function(pkg, repo){ | |
pkg <- as.character(as.list(match.call())$pkg) | |
repo <- as.character(as.list(match.call())$repo) | |
if ( !(pkg %in% as.data.frame(installed.packages())$Package) ){ | |
if( length(repo)!=0 ){ | |
package("devtools") | |
devtools::install_github(paste0(repo,"/",pkg)) | |
}else{ | |
install.packages(pkg) |
hello_world <- function() { | |
message( | |
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", | |
"* * * * HELLO WORLD * * * *\n", | |
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" | |
) | |
} | |
hello_world() |
# capturing failure with default values | |
library(purrr) | |
# a faulty function | |
f <- function(x){ | |
# some nasty error occuring once in a while | |
if( x %% 2 == 0 ){ |
// - check type of input | |
is_type_x = function(object, type){ | |
// go through cases: undefined, object, primitive | |
if( typeof(object) === "undefined" ){ | |
// undefined cannot be matched | |
return false; | |
} else if( typeof(object) === "object" ){ | |
// objects have to be matched against constructor | |
if( window[type] === undefined ){ |