This file contains hidden or 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 <Rcpp.h> | |
using namespace Rcpp ; | |
class abc { | |
public: | |
abc( SEXP x ) : data(x){} | |
inline operator SEXP() const { | |
return data ; | |
} |
This file contains hidden or 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
# The code below will probably only work on Linux and requires VLC on the path. | |
library(beepr) | |
library(stringr) | |
play_vlc <- function(fname) { | |
system(paste("open -a vlc --args --no-loop --no-repeat --playlist-autostart --no-media-library", fname), | |
ignore.stdout = TRUE, ignore.stderr=TRUE,wait = FALSE) | |
} | |
# Plays the mario theme while expr is executing, plays the flag pole jingle when the execution have finished. |
This file contains hidden or 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
``` | |
ir <- structure( iris, class = c("foo", "data.frame") ) | |
rbind.foo <- function(...) rbind.data.frame(...) | |
rbind(ir,iris) | |
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species | |
#ir Numeric,150 Numeric,150 Numeric,150 Numeric,150 factor,150 | |
#iris Numeric,150 Numeric,150 Numeric,150 Numeric,150 factor,150 | |
``` | |
So apparently we get the same as : |
This file contains hidden or 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 <Rinternals.h> | |
#include <Rinterface.h> | |
extern void* R_GlobalContext ; | |
#define R_NO_REMAP | |
#define USE_RINTERNALS | |
#include <R.h> | |
#include <Rinternals.h> |
This file contains hidden or 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
library(purrr) | |
library(github) # install_github("cscheid/rgithub") | |
library(dplyr) | |
library(stringr) | |
library(magrittr) | |
# Download issues --------------------------------------------------------- | |
ctx <- interactive.login("56b637a5baffac62cad9", "8e107541ae1791259e9987d544ca568633da2ebf") | |
issues1 <- get.repository.issues("hadley", "dplyr", per_page = 100) |
This file contains hidden or 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
library(rvest) | |
library(purrr) | |
library(tibble) | |
library(dplyr) | |
library(stringr) | |
attendees <- function(page) { | |
extract <- function(class) html_node( persons, class ) %>% html_text() %>% str_trim() | |
url <- paste0( 'https://user2017.sched.com/directory/attendees/', page ) |
This file contains hidden or 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
library(tidyverse) | |
library(lubridate) | |
library(emoGG) | |
lexie <- tribble( ~date, ~weight, | |
"2017-07-12", 3.460, | |
"2017-07-13", 3.200, | |
"2017-07-14", 3.100, | |
"2017-07-15", 3.200, | |
"2017-07-16", 3.250, |
This file contains hidden or 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
library(emo) | |
library(stringr) | |
library(purrr) | |
emoji_name <- emo:::emoji_name | |
emoji_keyword <- emo:::emoji_keyword | |
maybe_emoji <- function( keyword ){ | |
if (keyword %in% names(emoji_name)) { |
This file contains hidden or 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
.original.rs.getCompletionsFile <- .rs.getCompletionsFile | |
assign( ".rs.getCompletionsFile", function (token, path = getwd(), quote = FALSE, directoriesOnly = FALSE) { | |
if( grepl( ".*[:]", token ) ){ | |
tok <- sub( ".*[:]", "", token) | |
start <- sub( "[:].*", "", token) | |
.rs.makeCompletions( | |
token = token , results = paste0( start, emo::ji_completion(tok) ) , | |
excludeOtherCompletions = TRUE, type= .rs.acCompletionTypes$STRING, | |
quote = FALSE |
This file contains hidden or 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
percent <- function(x, digits = 2, format = "f", ...) { | |
paste0(formatC(100 * x, format = format, digits = digits, ...), "%") | |
} | |
mon_print <- function(synth){ | |
N <- nrow(synth) | |
if( is.null(N)){ | |
N<-1 | |
synth <- | |
matrix(synth,nrow=1) | |