Skip to content

Instantly share code, notes, and snippets.

View leoniedu's full-sized avatar

Eduardo Leoni leoniedu

  • IBGE
  • Salvador, Brazil
View GitHub Profile
url_sei <- "https://sei.economia.gov.br"
user_sei <- "usuario aqui"
pwd_sei <- "senha aqui"
org_sei <- "0" ## se tem mais de uma organizacao no login pode ter que mudar aqui.
library(RSelenium)
library(dplyr)
library(rvest)
library(purrr)
library(tictoc)
set.seed(20091975)
## number of stimuli
J <- 6
## draw the stimuli. hold them fixed
x <- sort(runif(J))
sim <- function(
N=100, ## number of individuals
intercept=0,
write('model {
for (i in 1:n.rows) {
y[i] ~ dnorm(y.hat[i], tau.y)
y.hat[i] <- b.0 + b.1 * x[i]
}
b.0 ~ dnorm (0, 1/(sdp^2))
b.1 ~ dnorm (0, 1/(sdp^2))
tau.y ~ dgamma(.0001, .0001)
sigma.y <- pow(tau.y, -(1/2))
plot.heat <- function(tmp,state.map,z,title=NULL,breaks=NULL,cex.legend=1,bw=.2,col.vec=NULL,main=NULL,plot.legend=TRUE, ...) {
tmp@data$zCat <- cut(tmp@data[,z],breaks,include.lowest=TRUE)
cutpoints <- levels(tmp@data$zCat)
if (is.null(col.vec)) col.vec <- heat.colors(length(levels(tmp@data$zCat)))
cutpointsColors <- col.vec
levels(tmp@data$zCat) <- cutpointsColors
cols <- as.character(tmp$zCat)
##cols <- "white"
plot(tmp,border=cols, lwd=bw,axes = FALSE, las = 1,col=as.character(tmp@data$zCat),main="A", ...)
if (!is.null(state.map)) {
## twitter poster for R
## allows delays
##based on http://www.cerebralmastication.com/?p=274
tweet.now <- function(status,userpwd="username:password") {
require(tcltk)
require("RCurl")
opts <- curlOptions(header = FALSE, userpwd = userpwd, netrc = FALSE)
method <- "http://twitter.com/statuses/update.xml?status="
encoded_status <- URLencode(status)
request <- paste(method,encoded_status,sep = "")
@leoniedu
leoniedu / Installing R on dreamhost
Created June 26, 2009 20:23
Installing R on dreamhost
## First do the unix account setup http://wiki.dreamhost.com/Unix_account_setup
cd ${HOME}
# create the first level directories (and log/setup)
mkdir -pv soft run www log log/setup backup data
# create the second level directories within run (our own FHS)
for subdir in bin etc include lib man share
do
mkdir -pv run/${subdir}
done
# symlink so that man pages stay all in the same place