Last active
January 23, 2018 19:32
-
-
Save rparatodxs/7faa3fc104fc1600f9203434fb44a00b to your computer and use it in GitHub Desktop.
Visualización de datos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------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"), | |
vSize="NOV2017", | |
vColor="NOV2017", | |
type="value", format.legend = list(scientific = FALSE, big.mark = " ")) | |
library(openxlsx) | |
setwd("C:/indices/IVC_ISUP/ENTREGABLES") | |
bd<-read.xlsx("Historico_IVC_Real_LDP_C_G_D_NOV2017 .xlsx" , 1) | |
library(treemap) | |
treemap(bd, | |
index=c("C", "LDP"), | |
vSize="NOV2017", | |
vColor="NOV2017", | |
type="value", format.legend = list(scientific = FALSE, big.mark = " ")) | |
#-----------VIM------------------ | |
setwd("C:/indices/IVC_ISUP/BASES_DATOS") | |
bd<-read.xlsx("BASE_SAS_COMERCIO_Ventas.xlsx" , 1) | |
library(VIM) | |
matrixplot(bd) | |
install.packages("ggplot2") | |
library(ggplot2) | |
# http://had.co.nz/ggplot2 | |
# qplot examples ------------------------------------------------------------- | |
qplot(diamonds$cut, diamonds$carat) | |
qplot(carat, price, data = diamonds) | |
qplot(carat, price, data = diamonds, colour=clarity) | |
qplot(carat, price, data = diamonds, geom=c("point", "smooth"), method=lm) | |
qplot(carat, data = diamonds, | |
geom="histogram") | |
qplot(carat, data = diamonds, | |
geom="histogram", binwidth = 1) | |
qplot(carat, data = diamonds, | |
geom="histogram", binwidth = 0.1) | |
qplot(carat, data = diamonds, | |
geom="histogram", binwidth = 0.01) | |
# using ggplot() ------------------------------------------------------------- | |
d <- ggplot(diamonds, aes(x=carat, y=price)) | |
d + geom_point() | |
d + geom_point(aes(colour = carat)) | |
d + geom_point(aes(colour = carat)) + scale_colour_brewer() | |
ggplot(diamonds) + geom_histogram(aes(x=price)) | |
# Separation of statistcs and geometric elements ----------------------------- | |
p <- ggplot(diamonds, aes(x=price)) | |
p + geom_histogram() | |
p + stat_bin(geom="area") | |
p + stat_bin(geom="point") | |
p + stat_bin(geom="line") | |
p + geom_histogram(aes(fill = clarity)) | |
p + geom_histogram(aes(y = ..density..)) | |
# Setting vs mapping --------------------------------------------------------- | |
p <- ggplot(diamonds, aes(x=carat,y=price)) | |
# What will this do? | |
p + geom_point(aes(colour = "green")) | |
p + geom_point(colour = "green") | |
p + geom_point(colour = colour) | |
###-----------tutorial en Harvard------------------ | |
http://tutorials.iq.harvard.edu/R/Rgraphics/Rgraphics.html | |
http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment