Skip to content

Instantly share code, notes, and snippets.

View cndesantana's full-sized avatar

cndesantana

  • https://datascout.com.br
  • datascout | dadoscope | cultour
View GitHub Profile
library(httr)
library(rvest)
library(lubridate)
library(tidyverse)
getCompromissos <- function(url){
web = GET(url)
compromissos = web %>%
read_html() %>%
@cndesantana
cndesantana / tweets_retweets_network.R
Created October 22, 2020 08:38
Creating a network of tweets and retweets with R
### Network analysis of tweets and retweets
library(rtweet)
library(tidyverse)
tw <- search_tweets("covid19", n=15000, retryonratelimit = TRUE)
tw %>% filter(is_retweet == TRUE) %>%
mutate(Source = screen_name, Target = retweet_screen_name) %>%
group_by(Target) %>%
mutate(tottarget = n()) %>%
@cndesantana
cndesantana / delivery_revenue_employees_dadoscope.R
Last active July 1, 2020 21:06
R script para plotar figuras descrevendo faturamento e número de empregados das maiores empresas de delivery do mundo. Usadas para post do Dadoscope no Twitter: https://twitter.com/Dadoscope1/status/1278413336074424320
### Dadoscope 2020
library(tidyverse)
library(waffle)
library(extrafont)
library(echarts4r)
library(fontawesome)
extrafont::font_import (path=".",
pattern = "awesome", prompt = FALSE)
@cndesantana
cndesantana / covid19_death_rate_NE
Last active June 16, 2020 20:41
COVID19 Death Rate of cities in NE Brazil with population greater than 600K and at least 100 deaths by COVID19
library(tidyverse)
library(lubridate)
link = "https://brasil.io/dataset/covid19/caso/?place_type=city&format=csv"
dat = read.csv(link, stringsAsFactors = FALSE)
dat <- dat %>% mutate(date = ymd(date))
png("hires.png", width=3200,height=1800,res=300)
dat %>%
@cndesantana
cndesantana / enquete_twitter.R
Created June 6, 2020 16:30
criando figura com parcial de enquete feita no twitter
library(rtweet)
library(tidyverse)
library(tidyr)
library(tidytext)
library(tm)
tw = search_tweets("to:RodZeidan",n= 8000)
tw_pesquisa = tw %>% filter(reply_to_status_id == "1269113444646649857", !is_retweet, !is_quote)
nresp = nrow(tw_pesquisa)
@cndesantana
cndesantana / mapasEleitorais.Rmd
Last active May 14, 2020 16:09
flexdashboard para apresentar dados eleitorais de SP em 2018
---
title: Mapas eleitorais
output: flexdashboard::flex_dashboard
runtime: shiny
---
```{r}
library(rnaturalearth)
library(wbstats)

Keybase proof

I hereby claim:

  • I am cndesantana on github.
  • I am cnsantana (https://keybase.io/cnsantana) on keybase.
  • I have a public key ASDOmnej1KsQI_xHZfd9CNl_wKaBS104RxI7lrkgw7rmXQo

To claim this, I am signing this object:

library(igraph)
nnodes = 100;#number of nodes is 100
g<-erdos.renyi.game(nnodes,0.07);#random graph with nnodes nodes
ypos<-round(runif(nnodes,min=0,max=3))#positions between 0 and 10
mysizes<-runif(nnodes,min=8,max=16)#sizes between 3 and 10
xpos<-runif(nnodes)
mylayout<-as.matrix(cbind(xpos,ypos))
png("./test.png",width=1980,height=1240,res=100)