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
# Functions usefull to display estimated equations | |
# Author: Paul Rougieux | |
# Function to output LaTeX equation based on an estimated model | |
# The goal is to display an estimated equation in latex form with coefficients in parenthesis | |
# Output can be used in an R Markdown file, provided the chunk option | |
# {r, results='asis'} has been set | |
lmdisplay = function(model){ | |
coefs = round(data.frame(t(summary(model)$coefficients[,1:2])),3) |
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
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" |
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 results='asis'} | |
for (f in list.files()){ | |
if(file.info(f)$isdir){ | |
l <- c(f, paste0(f,"/",list.files(f))) | |
cat(paste0("* [",c(f, list.files(f)),"]","(",l,")\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
library(dplyr) | |
# 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 |
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
library(dplyr) | |
library(nycflights13) | |
# 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")) |
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
#' 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: |
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
#LyX 2.1 created this file. For more info see http://www.lyx.org/ | |
\lyxformat 474 | |
\begin_document | |
\begin_header | |
\textclass article | |
\begin_preamble | |
\usepackage{booktabs} | |
\end_preamble | |
\options authoryear |
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
#' 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]] |
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
#LyX 2.1 created this file. For more info see http://www.lyx.org/ | |
\lyxformat 474 | |
\begin_document | |
\begin_header | |
\textclass article | |
\use_default_options true | |
\begin_modules | |
knitr | |
\end_modules | |
\maintain_unincluded_children false |
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
<<1stgenerationxtunitroot, results='asis'>>= | |
library(xtable) | |
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 | |
print(x.big,tabular.environment='longtable',floating=FALSE, | |
sanitize.text.function=function(str)gsub("footnote","\\footnote{my tricky footnote !!}",str,fixed=TRUE)) | |
@ |
OlderNewer