This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r, echo=FALSE, eval=TRUE} | |
title <- "the title" | |
``` | |
--- | |
title: `r title` | |
output: pdf_document | |
--- | |
In RStudio, this will automatically produce an html file, regardless of what is chosen. The html file that is produced renders correctly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void foo(const int *bar) | |
{ | |
printf("bar=%d\n", *bar); | |
} | |
int main() | |
{ | |
foo(&(int){27}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rcpp_code <- " | |
#include <Rcpp.h> | |
// [[Rcpp::export]] | |
double mcsim_rcpp(const int n){ | |
int i, r = 0; | |
double u, v; | |
Rcpp::RNGScope scope; | |
for (i=0; i<n; i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### This is free and unencumbered software released into the public domain. | |
code <- ' | |
#include <Rcpp.h> | |
#include <string> | |
// [[Rcpp::export]] | |
Rcpp::NumericVector CXX_factor_to_numeric(Rcpp::IntegerVector factor, std::vector<std::string> levels) | |
{ | |
Rcpp::NumericVector ret(factor.size()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat ~/.vim/after/ftplugin/vim.vim | |
setlocal foldmethod=syntax | |
$ cat ~/.vim/after/syntax/r.vim | |
setlocal foldmethod=syntax | |
setlocal foldenable | |
syn sync fromstart | |
set foldnestmax=1 | |
syn match vimFoldRoxygen "\v(^#'.*\n)+" fold containedin=ALLBUT,@vimNoFold | |
autocmd FileType r exe "normal zM``" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timezone <- function() | |
{ | |
time <- Sys.time() | |
ret <- list(timezone=format(time, format="%Z"), UTC.offset=format(time, format="%z")) | |
class(ret) <- "tzlookup" | |
return(ret) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### This is ludicrously expensive, but I couldn't quickly find a way to do it with methods:: functions. | |
is_s3_generic <- function(obj) | |
{ | |
m <- tryCatch(methods(obj), warning=identity, error=identity) | |
if (inherits(m, "warning") || inherits(m, "error")) FALSE else TRUE | |
} | |
find_generics <- function(pkg) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SUBROUTINE FIB(N) | |
INTEGER N,I,F0,F1,TMP | |
I=0 | |
1060 IF(N.GT.0)THEN | |
GOTO6129 | |
ELSE | |
GOTO7290 | |
ENDIF | |
6129 WRITE(*,3502) 1 | |
N=N-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat(sapply(99:1, function(i) paste(i, container <- ifelse(i>1, "bottles", "bottle"), "of beer on the wall,", i, container, "of beer. Take one down, pass it around,", ifelse(i > 1, paste(i-1, ifelse(i==2, sub("s", "", container), container), "of beer on the wall\n"), "No bottles of beer on the wall!\n")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@online{, | |
author = {Gabor Csardi}, | |
title = {{metacran}}, | |
year = 2015, | |
url = {https://github.com/metacran}, | |
urldate = {2015-5-10} | |
} |