[결과]



- 국내에서 치킨집이 폐업하는 건수는 평균적으로 연간 4-500건 대에 머무릅니다.


- 그런데, 2007년에는 3579건으로 거의 7~8배에 가까운 치킨집이 폐업을 하게 됩니다.


- 특이값인데, 그러면 2007년에는 어떤 일이 있었던 걸까? >> 서브프라임 모기지가 일어났던 해이기 때문으로 추측하고 있습니다.


- 치킨집의 비즈니스 특성상, 필수재가 아니기 때문에 단위당 경제가 악화 됨에 따라 매출이 줄어드는 정도가 매우 큰 편입니다. 쉽게 말해, 형편이 어려워지면 사람들이 밥은 줄이지 않아도 치킨은 줄인다는 말입니다.




[과정]


--환경 : oracle 11g database, sqlgate for oracle


--데이터 csv 파일 

폐업건수.csv



--폐업건수 테이블 생성

 create table endup

   (year  number(20),

   barber  number(30),

   western  number(30),

   japan   number(30),

   chiken   number(30),

   beverage  number(30),

   korean   number(30),

   beer   number(30) );

   


--년도별 치킨집 폐업건수 중 가장 폐업건수가 많은 년도

select item, year, cnt, rank() over(order by cnt desc nulls last) as rank

   from

   (

     select *

      from endup

      unpivot( cnt for item in (BARBER, WESTERN, JAPAN, CHIKEN, BEVERAGE, KOREAN, BEER) )

   )

   where item in 'CHIKEN';

반응형
Posted by JoeSung
,





## rvest를 통한 웹 스크래핑


install.packages("xml2")

library("xml2")

library("rvest")


url_tvcast = "http://tvcast.naver.com/jtbc.youth"

html_tvcast = read_html(url_tvcast, encoding = "UTF-8")


html_tvcast %>% html_nodes(".title a")

html_tvcast %>% html_nodes(".title a") %>% html_text()

tvcast_df = html_tvcast %>% html_nodes(".title a") %>% html_text() %>%

data.frame()


반응형
Posted by JoeSung
,

선행 블로깅

http://gigle.tistory.com/67



[결과물]



[코드]


[전국 댐 위치 시각화 with R]

:: 사용 코드

library(ggmap)

## ggmap이 버전이슈가 최근에 있어서 오류가 날지도 모른다.

## 그런 경우 install.packages("ggmap", type = "source") 를 통해 다시 설치하면 해결.

library(ggplot2)

a <- read.csv(file = "20170624.csv", sep = "," , header = TRUE)

## 파일을 불러오기

sub_a <- subset(a, TJL > 0, select = c("LON","LAT","TJL"))

## 위도와 경도만 가져와서 subset을 만듭니다.

str(sub_a)

cent <- c(lon = 127.8, lat = 35.8)


sub_a$test1 <- sub_a$TJL/1.7

sub_a

## 한국(남한)기준 위도 경도의 중심입니다.

map <- ggmap(get_googlemap(center = cent, zoom = 7, maptype='roadmap', color = 'bw'), extent = 'device')

## map 변수에 구글 지도(남한) 부분을 저장합니다.

map + geom_point(data = sub_a, aes(x=LON, y=LAT), colour = 'royalblue', alpha = 0.75, size = sub_a$TJL/1.3)

## size 변수를 통해 원의 크기를 조절 / alpha를 통해서 투명도를 조절 / data를 통해 사용할 데이터 가져오기


반응형
Posted by JoeSung
,