Skip to content

Instantly share code, notes, and snippets.

View fernandomayer's full-sized avatar

Fernando Mayer fernandomayer

View GitHub Profile
##======================================================================
## Script para baixar os livros disponibilizados gratuitamente pela
## Springer
## https://www.springernature.com/gp/librarians/news-events/all-news-articles/industry-news-initiatives/free-access-to-textbooks-for-institutions-affected-by-coronaviru/17855960
## 2020-04-03 FP Mayer
##======================================================================
##======================================================================
## Importa lista de livros
library(gdata)
```{r expo, echo=FALSE, results='hide'}
na <- 5
explanations <- questions <- character(na)
solutions <- logical(na)
## Auxilar function to calculate exponencial probabilities
probexp <- function(alfa, a, b){
exp(-alfa * a) - exp(-alfa * b)
}
@fernandomayer
fernandomayer / rnw2rmd.pl
Created February 16, 2018 20:46 — forked from lgatto/rnw2rmd.pl
Convert Rnw to Rmd
#!/usr/bin/perl
## Based on rnw2rmd.pl by Laurent Gatto
## https://gist.github.com/lgatto/d9d0e3afcc0a4417e5084e5ca46a4d9e
## The script ignores labels and references, un-numbered sections
## (section*), quotes and probably a couple of more. It won't deal
## with the pre-amble, bibliography and document tags either. Still
## useful, though.
name: ce083
output_dir: docs
exclude:
- README.md
- \.sh
output:
html_document:
theme: flatly
highlight: default
code_folding: hide
## Segmented regression plots in lattice
## Example for view purposes only
head(iris)
library(xyplot)
xyplot(Sepal.Length ~ Sepal.Width, iris,
panel = function(x, y, ...){
panel.xyplot(x, y, ...)
le <- lm(Sepal.Length ~ Sepal.Width, iris,
subset = Sepal.Width <= 3)
llines(iris$Sepal.Width[iris$Sepal.Width <= 3],
---
title: "Some very clever title here"
author: "Author 1, Author 2"
date: "February, 2016"
output: html_document
---
```{r setup, include=FALSE, purl=FALSE, eval=TRUE}
opts_chunk$set(
## knitr options
@fernandomayer
fernandomayer / source_https.R
Last active July 17, 2020 11:09
This function allows you to source individual R files from a GitHub repository. Author: Tony Breyal, with contributions from Kay Cichini. Source: http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
source_https <- function(url, ...) {
## Function for sourcing individual R scripts from GitHub
## Author: Tony Breyal
## Contributions: Kay Cichini
## Original URL: http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
## Load required package
require(RCurl)
## Parse and evaluate each .R script
sapply(c(url, ...), function(u) {
eval(parse(text = getURL(u, followlocation = TRUE,
@fernandomayer
fernandomayer / CMR.R
Created January 31, 2013 00:01 — forked from benilton/CMR.R
## Este exemplo provê um código em R que outros usuários podem reproduzir
## para facilitar a solução de problemas observados.
##
## Na R-br em: http://r-br.2285057.n4.nabble.com/R-br-Produzindo-um-Codigo-Minimo-Reproduzivel-CMR-td3674188.html
#################################################################
## PASSO 1: Carregue os pacotes necessários no início do código
#################################################################
library(splines)
n_sims = 1_000_000
mle_se = zeros(n_sims)
unbiased_se = zeros(n_sims)
yatracos_std_se = zeros(n_sims)
kourouklis_std_se = zeros(n_sims)
for sim in 1:n_sims
n = 10
x = randn(n)
@fernandomayer
fernandomayer / script_jekyll.R
Created August 2, 2012 00:39
Teste script for Jekyll
require(devtools)
install_github("FishMaps", username = "fernandomayer")
# use mapLL
mapLL()
# function
hw <- function(){
cat("Hello world!")
}