Skip to content

Instantly share code, notes, and snippets.

@rparatodxs
rparatodxs / MeteoChile_2019.R
Created June 21, 2019 19:36
Webscrap del sitio meteochile version nueva
library(rvest)
#sitio web donde se "toma la decisión" sobre que estación, año, mes extraer (hay que agregar valores)
url <- html_session("https://climatologia.meteochile.gob.cl/application/index/productos/RE1005")
#extraer la "form" que se debe completar
quesepuederellenar <- html_form(url)
extraercamposarellenar <- quesepuederellenar[[1]]
#Vamos a extraer valores para todos los meses de una estación el año 2018
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE TotalUL")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE PanelMensual_PF")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE VentasMesFP")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE CodRec_2018P")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE CuentaOrigP")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE CuentaRectP")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE NoCoincidentes")
bd<-RODBC::sqlQuery(channel = myconn,query = "select * from VentasMesFP")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE oriP")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE recP")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE CodOri_2019P")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE CodRec_2019P")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE CuentaOrigP")
#RODBC::sqlQuery(channel = myconn,query = "DROP TABLE CuentaRectP")
#/*Tiempo de ejecución OCT2019 00:40:34*/
@rparatodxs
rparatodxs / venta_final.txt
Last active March 1, 2019 11:56
venta_final
rm(list=ls())
library(RODBC)
library(sqldf)
myconn <-odbcConnect("validacion_karina")
sqlTables(myconn , tableType = "TABLE")
@rparatodxs
rparatodxs / innobd.txt
Last active September 3, 2018 17:38
revisión bd
rm(list=ls())
setwd("C:/Users/Jbustos/Documents/Jose_Bustos/Innoprint_2018/")
bd<-read.csv2("Innoprint_meses.csv", sep=";", dec=",", h=T)
bd_kiwi<-read.csv2( "Kiwi_meses.csv" , sep=";", dec=",", h=T)
#----arreglo de las temporadas a meses años-----
bd$año[bd$TEMPORADA=="TEMP.2011-2012" & bd$MES=="Septiembre"] <- 2011
bd$año[bd$TEMPORADA=="TEMP.2011-2012" & bd$MES=="Octubre"] <- 2011
bd$año[bd$TEMPORADA=="TEMP.2011-2012" & bd$MES=="Noviembre"] <- 2011
library(ggplot2)
library(dplyr)
library(deldir)
library(colourlovers)
library(rlist)
# Parameters
iter=3 # Number of iterations (depth)
points=14 # Number of points
radius=1.14 # Factor of expansion/compression
# Load in libraries
library(ggplot2)
library(dplyr)
library(deldir)
# Parameters to change as you like
iter=3 # Number of iterations (depth)
points=6 # Number of points
radius=3.8 # Factor of expansion/compression
#---Harvard Ejemplos de Estudio----------
#http://tutorials.iq.harvard.edu/R/Rgraphics/Rgraphics.html
setwd("C:/Users/Jbustos/Documents/CURSO_R/Curso_R_INE_2018/datos/Rgraphics/Rgraphics")
housing <- read.csv("dataSets/landdata-states.csv")
head(housing[1:5])
hist(housing$Home.Value)
library(ggplot2)
ggplot(housing, aes(x = Home.Value)) +
geom_histogram()
@rparatodxs
rparatodxs / treemap
Last active January 23, 2018 19:32
Visualización de datos
#------------------visualización estadisticas oficiales-----------------
library(openxlsx)
library(treemap)
setwd("C:/indices/IVC_ISUP/ENTREGABLES")
bd<-read.xlsx("Historico_IVC_Real_LDP_C_G_D_NOV2017 .xlsx" , 1)
#---------treemap
treemap(bd,
index=c("C", "LDP"),
##-----ESTA ES UN REPLICA DE VARIOS EJEMPLOS DE COMO HACER UN ANALISIS DE SENTIMIENTO EN R----
#----1. conectar r con twitter
#----desde tu cuenta de twitter crea una api en el sitio de twitter: https://apps.twitter.com/
#----luego hay hacer la coneccion, para lo que hay q obtener:
library(twitteR)
library(ROAuth)
library(httr)