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(ggplot2) | |
library(ggrepel) | |
library(readr) | |
## votacao por municipio, candidato e cargo | |
vmc <- readr::read_rds("~/Downloads/20241007_151828_eleicao24_prefeitos_vereadores_finalizados.rds") | |
## por cargo, municipio, partido | |
vmp <- vmc%>% |
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
#' Convertion to title case with lower case for some classes of words. | |
#' | |
#' In written Portuguese, when converting to title case, it is not usual | |
#' to keep in title case some words, like prepositions, conjunctions, | |
#' articles and some kinds of pronouns. This functions locates those | |
#' cases and converts them to lower case. Based on gist ToTitleCasePT https://gist.github.com/jjesusfilho/454192db8356eb9c486a02698338221a by https://github.com/jjesusfilho | |
#' | |
#' @param string vector of characters to be converted to title case | |
#' but with connector words (one-word prepositions and conjunctions) | |
#' and articles (both definite and indefinite) and some pronouns |
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
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) |
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
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, |
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
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)) |
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
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)) { |
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
## 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 = "") |
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
## 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 |