r:googlevis
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
r:googlevis [2017/06/07 09:17] – [Places in Jeju] hkimscil | r:googlevis [2017/06/07 17:23] (current) – [Public Parking Places] hkimscil | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Worldbank data e.g. ====== | ====== Worldbank data e.g. ====== | ||
- | < | + | < |
+ | demo(googleVis)</ | ||
+ | |||
+ | < | ||
+ | Sys.setlocale(category = " | ||
+ | install.packages(" | ||
library(googleVis) | library(googleVis) | ||
demo(WorldBank)</ | demo(WorldBank)</ | ||
- | |||
{{youtube> | {{youtube> | ||
- | |||
< | < | ||
## Sys.setlocale(" | ## Sys.setlocale(" | ||
+ | Sys.setlocale(category = " | ||
## SOURCE: http:// | ## SOURCE: http:// | ||
Line 173: | Line 177: | ||
====== Seoul District Office marking ====== | ====== Seoul District Office marking ====== | ||
- | ====== | + | ====== |
+ | < | ||
+ | CityPopularity | ||
+ | ex1 < | ||
+ | | ||
+ | | ||
+ | | ||
+ | plot(ex1) | ||
+ | </ | ||
+ | ====== Pie charts ====== | ||
+ | < | ||
+ | CityPopularity | ||
+ | pie1 <- gvisPieChart(CityPopularity, | ||
+ | plot(pie1)</ | ||
+ | |||
+ | ====== Bar charts ====== | ||
+ | < | ||
+ | fruits=data.frame(month=c(" | ||
+ | apple=c(30, | ||
+ | | ||
+ | line <- gvisLineChart(fruits) | ||
+ | plot(line) | ||
+ | |||
+ | # 양쪽면에 y축 표시하기 | ||
+ | line2 <- gvisLineChart(fruits," | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | plot(line2) | ||
+ | |||
+ | # 선모양 변경하기 | ||
+ | line3 <- gvisLineChart(fruits, | ||
+ | | ||
+ | linewidth: | ||
+ | | ||
+ | linewidth: | ||
+ | vAxes=" | ||
+ | plot(line3) | ||
+ | |||
+ | |||
+ | </ | ||
+ | < | ||
+ | plot(gbar) | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====== Bubble charts ====== | ||
+ | < | ||
+ | Fruits | ||
+ | a <- gvisBubbleChart(Fruits, | ||
+ | | ||
+ | | ||
+ | hAxis=' | ||
+ | plot(a)</ | ||
+ | |||
+ | ====== Public Parking Places ====== | ||
< | < | ||
+ | setwd(" | ||
install.packages(" | install.packages(" | ||
- | library(googleVis) | + | install.packages(" |
library(ggmap) | library(ggmap) | ||
+ | library(stringr) | ||
+ | |||
+ | loc <- read.csv(" | ||
+ | loc | ||
+ | kd <- get_map(" | ||
+ | |||
+ | kor.map <- ggmap(kd)+geom_point(data=loc, | ||
+ | size=3, | ||
+ | kor.map + geom_text(data=loc, | ||
+ | ggsave(" | ||
+ | |||
+ | # 시립 구립 구분하기 | ||
+ | loc2 <- str_sub(loc$주차장명, | ||
+ | loc2 | ||
+ | colors <- c() | ||
+ | for ( i in 1: | ||
+ | if (loc2[i] == ' | ||
+ | | ||
+ | else { | ||
+ | colors <- c(colors," | ||
+ | } | ||
+ | |||
+ | kd <- get_map(" | ||
+ | kor.map <- ggmap(kd)+geom_point(data=loc, | ||
+ | | ||
+ | kor.map + geom_text(data=loc, | ||
+ | ggsave(" | ||
+ | |||
+ | |||
+ | </ | ||
+ | ====== Places in Jeju ====== | ||
+ | < | ||
+ | install.packages(" | ||
+ | install.packages(" | ||
+ | |||
+ | Sys.setlocale(" | ||
+ | library(googleVis) | ||
+ | library(ggmap) | ||
+ | |||
ft_placelst <- function(place) { | ft_placelst <- function(place) { | ||
- | temp <- geocode(place) | + | |
- | | + | place <- gsub("제주 |
- | | + | df_lst <- cbind(place, |
- | | + | return(df_lst) |
} | } | ||
- | + | ||
- | df_placelst <- ft_placelst(readLines(" | + | df_placelst <- ft_placelst(readLines(" |
latlong <- paste(df_placelst$lat,":", | latlong <- paste(df_placelst$lat,":", | ||
latlong <- gsub(" ","", | latlong <- gsub(" ","", | ||
- | + | ||
df_placelst <- cbind(df_placelst, | df_placelst <- cbind(df_placelst, | ||
df_placelst | df_placelst | ||
Line 200: | Line 301: | ||
width=800, | width=800, | ||
plot(placePath) | plot(placePath) | ||
+ | |||
</ | </ | ||
- | + | ====== Population by districts ====== | |
+ | < | ||
+ | library(ggmap) | ||
+ | library(grid) | ||
+ | pop <- read.csv(" | ||
+ | pop | ||
+ | lon <- pop$LON | ||
+ | lat <- pop$LAT | ||
+ | data <- pop$총인구수 | ||
+ | df <- data.frame(lon, | ||
+ | df | ||
+ | map1 <- get_map(" | ||
+ | map1 <- ggmap(map1) | ||
+ | map1 + geom_point(aes(x=lon, | ||
+ | ggsave(" | ||
+ | </ | ||
r/googlevis.1496796438.txt.gz · Last modified: 2017/06/07 09:17 by hkimscil