Skip to content

Instantly share code, notes, and snippets.

View gomesfellipe's full-sized avatar
🤘
Working..

Fellipe gomesfellipe

🤘
Working..
View GitHub Profile
library(tidyverse)
library(lubridate)
library(sidrar)
# Obter IPCA --------------------------------------------------------------
ipca_indice = get_sidra(api='/t/1737/n1/all/v/2266/p/all/d/v2266%2013') %>%
as_tibble() %>%
select(-`Nível Territorial`, -`Nível Territorial (Código)`,
-`Unidade de Medida`, -`Unidade de Medida (Código)`,

Based on the example code on https://www.tidymodels.org/learn/models/parsnip-nnet/

library(tidymodels)
#> ─ Attaching packages ──────────────────────────────────────────── tidymodels 0.1.0 ─
#> ✓ broom     0.5.6          ✓ recipes   0.1.12    
#> ✓ dials     0.0.6          ✓ rsample   0.0.6     
#> ✓ dplyr     0.8.5          ✓ tibble    3.0.1     
#> ✓ ggplot2   3.3.0.9000     ✓ tune      0.1.0     
#> ✓ infer     0.5.1          ✓ workflows 0.1.1     
@gomesfellipe
gomesfellipe / spleeter_music_instruments_wav.py
Last active March 13, 2021 17:06
Script used to obtain instruments for a music using the spleeter library from deezer
# Referencias:
# https://github.com/deezer/spleeter
# !conda install -c conda-forge ffmpeg libsndfile
# !pip install spleeter
from spleeter.separator import Separator
separator = Separator('spleeter:5stems')
@gomesfellipe
gomesfellipe / dias_de_vida.R
Created February 3, 2021 16:21
Calcular dias de vida em R e em Python
# R ----------------------------------------------------------------------------
born <- as.Date("1993-12-14")
today <- Sys.Date()
# Quantos dias de vida
difftime(today, born)
# Completa 10.000 dias de vida em:
born+days(10000)
@gomesfellipe
gomesfellipe / gapminder_automatico_master.Rmd
Created September 13, 2019 04:29
Script para produção de relatórios automáticos
---
title: "Gapminder: Relatorio Automático"
autor: "Fellipe Gomes"
output: pdf_document
---
```{r setup_master, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@gomesfellipe
gomesfellipe / gapminder_automatico_child.Rmd
Last active March 22, 2020 03:56
Arquivo para produção de relatórios automáticos
---
title: "Untitled"
output: pdf_document
---
```{r, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
# Dados do looping:
x <- nested_gapminder$data[[i]]
# Inluir no global -------------------------------------------------------
Logged = FALSE
my_username <- "appgenalim"
my_password <- "genalim"
# -------------------------------------------------------------------------
# Autenticacao ------------------------------------------------------------
## Incluir codigo abaixo no servidor
values <- reactiveValues(authenticated = FALSE)
@gomesfellipe
gomesfellipe / Integração_SITE_DE_AUTENTICACAO.R
Created May 6, 2019 21:20
Exemplo de como implementar a autenticação a partir da resposta da GM5
# Exemplo de como implementar a autenticação a partir da resposta da GM5:
library(RCurl)
headerFields =
c(Accept = "text/xml",
Accept = "multipart/*",
'Content-Type' = "text/xml; charset=utf-8",
SOAPAction = "http://tempuri.org/authToken")
# Codigo inspirado neste post:
# https://www.business-science.io/code-tools/2017/10/24/demo_week_timetk.html
# Testando se o ajuste funciona para a serie AirPassenger
# Nao sei ate que ponto este metodo esta correto... Vamos estudar!
library(tsibble)
library(lubridate)
library(dplyr)
library(timetk) # Toolkit for working with time series in R
@gomesfellipe
gomesfellipe / detectar_e_extrair_string.R
Last active May 7, 2019 14:39
Exemplo simples de como detectar e extrair determinada string utilizando o pacote `stringr` (Jeito nutella)
library(stringr)
# Neste exemplo vamos obter tudo que venha apos
# a string "&token=":
# Link de exemplo:
link <- "http://www.google.com/aclk?sa=l&ai=DChcSEwi2vazh_ujhAhWHDJEKHcJaBWYYABAAGgJjZQ&token=AOD64_2roKLol2MibXGLfO6uavtAm10Hhw&ved=0ahUKEwiN26fh_ujhAhV7GLkGHUZSD6cQ0QwIFA&adurl="
# Primeiro vamos localizar a posicao
# inicial da string desejada
posicao_inicial <- str_locate(link ,"&token=")[,"start"]