Skip to content

Instantly share code, notes, and snippets.

View Athospd's full-sized avatar
🏠
Working from home

Athos Petri Damiani Athospd

🏠
Working from home
View GitHub Profile
@Athospd
Athospd / litig_idh_us.R
Last active August 29, 2015 13:56
Litigiosidade vs IDH dos Estados Americanos
require(httr)
require(XML)
require(ggplot2)
# dados de IDH por estado americano do Wikipedia
resp <- GET("http://en.wikipedia.org/wiki/List_of_U.S._states_by_American_Human_Development_Index")
html <- htmlParse(content(resp, as="text"))
htmlTable <- readHTMLTable(html, header = TRUE, stringsAsFactors = FALSE)
# IDH
@Athospd
Athospd / esboco_cv.R
Created September 10, 2014 23:44
Esboço tosqueira de Cross-validation
library(glmnet)
X = model.matrix(rchp ~ 1
+ jogo_do_brasil*(competicao
+ jogo_do_brasil
+ fase2
+ jogo_do_n1
+ jogo_da_italia
+ I(log(soma_ranking))
+ I(log(produto_ranking))
@Athospd
Athospd / tab_condensada_pander.Rmd
Created November 5, 2014 23:53
Exemplo de tabela condensada com pander em RMarkdown
---
title: "Exemplo Tabelas com Pander em RMarkdown"
author: "Athos"
date: "Wednesday, November 05, 2014"
output: html_document
---
```{r}
library(pander)
library(magrittr)
@Athospd
Athospd / server.R
Last active January 5, 2021 11:15
Trying to manipulate shiny reactiveValues objects
library(shiny)
library(magrittr)
shinyServer(function(input, output, session) {
#__________________________________________________________________________________
# The main named list that will be used in many other tasks.
listN <- reactiveValues()
#__________________________________________________________________________________
@Athospd
Athospd / matriz_de_betas
Created February 25, 2015 00:38
desenha uma matriz de distribuições beta com diferentes parâmetros em ggplot2
# matriz de betas!
library(ggplot2)
library(dplyr)
# parâmetros da beta
a <- b <- c(0.1,0.5,1,2,3)
# pontos pra fazer a linha
x <- seq(0, 1, len = 100)
library(keras)
library(dplyr)
logit <- function(p) log(p) - log(1 - p)
inv_logit <- function(x) 1/(1 + exp(-x))
n <- 10000
set.seed(19880923)
df <- data.frame(x = rnorm(n)) %>%
mutate(y_1 = rbinom(n, 1, prob = inv_logit(-1 + 4 * x)) %>% as.factor,
@Athospd
Athospd / r_telegram_bitcoin.R
Created August 24, 2017 02:51
simple app for track and get notifications on telegram from R about bitcoin prices.
library(stats)
library(tidyverse)
library(httr)
library(jsonlite)
library(telegram)
## Create the bot object
bot <- TGBot$new(token = bot_token('AthosDamianiBot'))
bot$getMe()
library(readr)
library(stringr)
library(tidyr)
library(dplyr)
library(purrr)
library(tokenizers)
library(forcats)
reviews <- read_lines("finefoods.txt.gz")
reviews <- reviews[str_sub(reviews, 1, 12) == "review/text:"]
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\Anaconda3\envs\athos\lib\site-packages\numpy\core\__init__.py in <module>
15 try:
---> 16 from . import multiarray
17 except ImportError as exc:
~\Anaconda3\envs\athos\lib\site-packages\numpy\core\multiarray.py in <module>
11
---> 12 from . import overrides
library(RSQLite)
library(tidyverse)
library(dbplyr)
con <- RSQLite::dbConnect(RSQLite::SQLite(), "database.sqlite")
nome_das_tabelas <- RSQLite::dbListTables(con)
tabelas <- nome_das_tabelas %>%
map(~dbplyr::db_collect(con, glue::glue("select * from {.x}"))) %>%