Skip to content

Instantly share code, notes, and snippets.


Paul Rougieux paulrougieux

View GitHub Profile
paulrougieux / knitrchunk
Last active Nov 19, 2015
Add a footnote in a table generated by xtable inside a Lyx document (answer from
View knitrchunk
<<1stgenerationxtunitroot, results='asis'>>=
x <- matrix(rnorm(60), ncol = 10)
x.big <- xtable(x,label='tabbig', caption='Example of longtable')
names(x.big) <- LETTERS[1:10]
names(x.big)[9] <- paste('I','footnote') # I put the tag on I letter
sanitize.text.function=function(str)gsub("footnote","\\footnote{my tricky footnote !!}",str,fixed=TRUE))
paulrougieux / hyphen.lyx
Last active Nov 5, 2015
Hyphens are not printed when printing from the evince PDF viewer on Debian
View hyphen.lyx
#LyX 2.1 created this file. For more info see
\lyxformat 474
\textclass article
\use_default_options true
\maintain_unincluded_children false
paulrougieux / countwordpersentence.R
Last active Oct 30, 2015
Count the number of words per sentence
View countwordpersentence.R
#' Separate the input text in sentences and count the number of words per sentence
#' @param blabla character vector containing a single text string.
#' @param minwordpersentence number minimum of word that a sentence should
#' have so that it is taken into account
#' @return a list countaining the number of sentence, wordcount,
#' mean number of words per sentence and total word count.
#' @export
countwordpersentence <- function(blabla, minwordpersentence = 2){
blabla <- strsplit(blabla,"\\.")[[1]]
View knitr_iris.lyx
#LyX 2.1 created this file. For more info see
\lyxformat 474
\textclass article
\options authoryear
paulrougieux / octave.R
Last active Aug 29, 2015
Create and execute an Octave file
View octave.R
#' Create and execute an Octave file
#' This function creates 2 files in the working directory:
#' \itemize{
#' \item{filename.m contains an Octave (Matlab) script}
#' \item{filename.csv contains estimation results}
#' }
#' Variables filename and
#' allitems are currently used as mustache tag variables.
#' More information on the Mustache format:
paulrougieux / dplyrsql.R
Last active Aug 29, 2015
Display SQL statement from dplyr chained operations
View dplyrsql.R
# Create a SQLite databse
my_db <- src_sqlite("my_db.sqlite3", create = T)
flights_sqlite <- copy_to(my_db, flights,
temporary = FALSE,
indexes = list(c("year", "month", "day"),
"carrier", "tailnum"))
paulrougieux / STATA.R
Last active Aug 29, 2015
Create and execute a STATA do file passing some variables as mustache tags
# Estimate a panel data model using plm and STATA
# Transmit some variables to STATA using mustache tags
# Write panel data to csv for use in STATA
write.csv(Grunfeld, path, item_, ".csv", names = FALSE, na = ".")
#' Create and execute a STATA do file
paulrougieux / list_files_mardown.R
Last active Aug 29, 2015
List of link to files in 2 level directory, useable in Markdown
View list_files_mardown.R
```{r results='asis'}
for (f in list.files()){
l <- c(f, paste0(f,"/",list.files(f)))
cat(paste0("* [",c(f, list.files(f)),"]","(",l,")\n"))
paulrougieux / FAOregioncodes.R
Last active Aug 29, 2015
FAOregioncodes for the FAOSTAT module
View FAOregioncodes.R
FAOregioncodes <- structure(list(FAOST_CODE = c(5000L,
5100L, 5101L, 5102L, 5103L, 5104L, 5105L, 5200L, 5203L, 5204L,
5206L, 5207L, 5300L, 5301L, 5302L, 5303L, 5304L, 5305L, 5400L,
5401L, 5402L, 5403L, 5404L, 5500L, 5501L, 5502L, 5503L, 5504L,
5600L, 5706L, 5801L, 5802L, 5803L, 5815L, 5817L, 5848L, 5849L),
Region = structure(c(37L, 1L, 10L, 20L, 23L, 31L, 34L, 2L,
24L, 8L, 7L, 30L, 5L, 9L, 11L, 32L, 29L, 35L, 13L, 12L, 25L,
33L, 36L, 26L, 6L, 18L, 19L, 27L, 4L, 14L, 16L, 15L, 28L, 17L,
21L, 3L, 22L),
.Label = c("Africa", "Americas", "Annex I countries"
You can’t perform that action at this time.