Skip to content

Instantly share code, notes, and snippets.

View rfsaldanha's full-sized avatar

Raphael Saldanha rfsaldanha

View GitHub Profile
@rfsaldanha
rfsaldanha / mapa_exemplo.R
Created August 3, 2022 13:03
Exemplo de mapa utilizando as bibliotecas ggplot2 e geobr
# Pacotes
library(tidyverse)
# remotes::install_github("ipeaGIT/geobr", subdir = "r-package")
library(geobr)
# Dados
df_simu_curso_orig <- read.csv('https://drive.google.com/uc?export=download&id=17ZmUSdC0G4S1OUBpqUzllXqPlOLP1pVD')
# Mapa
uf_mapa <- read_municipality()
@rfsaldanha
rfsaldanha / script_microdatasus_sqlite.R
Created June 13, 2022 13:20
microdatasus with SQLite
# Pacotes
library(microdatasus)
library(tidyverse)
library(dbplyr)
library(DBI)
library(RSQLite)
# Cria conexão com o banco de dados
conn <- dbConnect(RSQLite::SQLite(), "sih.SQLite")
@rfsaldanha
rfsaldanha / epifortnight.R
Last active November 18, 2021 21:23
Epidemiological fortnight at R with `lubridate` package
epifortnight <- function(x){
x <- as.POSIXlt(x)
date <- lubridate::make_date(year(x), month(x), day(x))
wday <- lubridate::wday(x, week_start = 7)
date <- date + (4 - wday)
jan1 <- as.numeric(lubridate::make_date(year(date), 1, 1))
1L + (as.numeric(date) - jan1) %/% 15L
}
@rfsaldanha
rfsaldanha / cron_speedtest.sh
Created August 18, 2021 22:14 — forked from ntrepid8/cron_speedtest.sh
Script to run speedtest-cli via cron and log the results
#!/usr/bin/env bash
LOG_PATH="/home/$(whoami)/log/speedtest.log"
if result=$(/usr/bin/speedtest --simple); then
parsed_result=$(printf "${result}\"" | sed ':a;N;$!ba;s/\n/" /g' | sed 's/: /="/g')
printf "[$(date)] ${parsed_result}\n" >> "${LOG_PATH}"
else
printf "[$(date)] error\n" >> "${LOG_PATH}"
exit 1