Skip to content

Instantly share code, notes, and snippets.

View cderv's full-sized avatar

Christophe Dervieux cderv

View GitHub Profile
@cderv
cderv / README.md
Created September 23, 2015 17:15 — forked from romainfrancois/README.md
getting github issues for a given repo

Simple R script that grabs the opened issues from a github repo :

$ github_issues hadley/dplyr
   number           user                                                         title                labels
1      98         hadley                                   Setup databases with travis           enhancement
2      97         hadley                                               Unique operator           enhancement
3      96         hadley                           Implement right join and outer join           enhancement
4      95 romainfrancois                                             Hybrid evaluation enhancement, internal
5      94         hadley                 Make sure all vignettes work from R CMD check                   bug
@cderv
cderv / RStudio_snippet.md
Last active October 22, 2020 17:07
my custom snippet for RStudio

To insert YAML header for Rnotebook

snippet yaml_notebook_html
	#' ---
	#' title: "${1:title}"
	#' author: "${2:author}"
	#' knit: (function(inputFile, encoding) { rmarkdown::render(inputFile, encoding = encoding, output_file = sprintf("%s_%s.html", format(Sys.Date(), "%y%m%d"), basename(tools::file_path_sans_ext(inputFile))))})
	`r paste("#' date: '\u0060r paste(\u0022", format(Sys.time(), "%d/%m/%Y")," - Dernière MAJ:\u0022, format(Sys.time(), \u0022%d/%m/%Y\u0022))\u0060'", sep = "")`
	#' output : 
	#' html_document:
@cderv
cderv / Theme_Markdown.css
Created February 13, 2016 15:02
Template for custome documenth
h1{
color: white;
padding: 10px;
background-color: #3399ff
}
ul {
list-style-type: square;
}
@cderv
cderv / Config_proxy.R
Last active October 22, 2020 17:07
Proxy Configuration
# Read a pasword using a prompt
read_Password <- function(prompt) {
if (requireNamespace("rstudioapi")) {
pwd <- rstudioapi::askForPassword(prompt)
} else if (exists(".rs.askForPassword")) {
pwd <- .rs.askForPassword(prompt)
} else {
pwd <- readline(prompt)
}
return (pwd)
@cderv
cderv / about_download_methods.md
Last active January 12, 2024 02:43
download file methods in R

download.file methods in R

Working on a PR for remotes package (this PR), I looked into how download.file methods evolved with R version, trying to understand how it works depending on the system or the url type.

Here is my understanding.

History of download.file

from R news

R 3.3.0

@cderv
cderv / nested_list_data.R
Last active June 10, 2020 20:59
data for nested list example
#' From a stackoverflow question : https://stackoverflow.com/questions/46128164/extract-data-from-a-nested-list-with-loops#46128164
nested_list_ex <- structure(list(scheduleList = structure(list(
schedule = structure(list(
score = structure(list(
class = structure(list(name = list("011c"), people = list("2"), teacher = structure(list(name = list("A")), .Names = "name", id = "D29")), .Names = c("name", "people", "teacher"), id = "011c", status = "-2"),
class = structure(list(name = list("013"), people = list("0"), teacher = structure(list(name = list("B")), .Names = "name", id = "D14")), .Names = c("name", "people", "teacher"), id = "602d", status = "-4"),
class = structure(list(name = list("603"), people = list("6"), teacher = structure(list(name = list("C")), .Names = "name", id = "D31")), .Names = c("name", "people", "teacher"), id = "603", status = "-4")),
.Names = c("class", "class", "class"), id = "1"),
score = structure(list(
class = structure(list(name = list
@cderv
cderv / example.R
Last active October 5, 2017 19:24
TidyEvalution with testthat
library(testthat)
library(lubridate)
base <- as.POSIXct("2009-08-03 12:01:59.23", tz = "UTC")
expect_floor_equal <- function(unit, time) {
unit <- rlang::enquo(unit)
time <- rlang::enquo(time)
as_time <- function(x) as.POSIXct(x, tz = "UTC")
rlang::expr(expect_equal(floor_date(base, rlang::UQE(unit)), as_time(rlang::UQE(time))))
@cderv
cderv / About_Packrat.md
Last active November 8, 2017 09:26
How Packrat work

Fonction getPackageRecords

Parse description and call inferPackageRecord. Produce a table parsing the Description file

  1. Package desc field
  2. Version desc field
  3. Repo from getOption("repo")
  4. (optionnaly) GithubRepo desc field (Where does it come from ? devtools::install_github ?). if found, then return the table with dcf field
(CNN) -- Can a movie actually convince you to support torture? Can a movie really persuade you that "fracking" -- a process used to drill for natural gas -- is a danger to the environment? Can a movie truly cause you to view certain minority groups in a negative light?
Some scoff at the notion that movies do anything more than entertain. They are wrong. Sure, it's unlikely that one movie alone will change your views on issues of magnitude. But a movie (or TV show) can begin your "education" or "miseducation" on a topic. And for those already agreeing with the film's thesis, it can further entrench your views.
Anyone who doubts the potential influence that movies can have on public opinion need to look no further than two films that are causing an uproar even before they have opened nationwide. They present hot button issues that manage to fire up people from the left and right.
The first, "Zero Dark Thirty," is about the pursuit and killing of Osama bin Laden, which features scenes of torture. The second,
@cderv
cderv / Notes.md
Last active February 9, 2018 19:53
Some stuff to remember on R

How to set RLIBS ?

R_LIBS='<somelibrarypath>:<someotherlibrarypath>'

How configure.args and configure.vars are resolved ?

They can be provided as a named list and this is resolved by install.packages using package name.

Can they be use with devtools.install.args ?