README.md

seoulsubway

서울 지하철에 대한 내용이 담겨 있는 패키지입니다.

이 패키지 내에는 서울 지하철에 대한 정보와 최단거리 함수 그리고 지도상의 표현이 가능한 함수가 포함되어 있습니다.

contact: kinh4k@g.skku.edu

Install!

devtools::install_github("king4k1/seoulsubway") 를 통하여 설치가능하며,

5000건의 경로 데이터샘플인 subway_sample를 이용하여 함수를 테스트하실 수 있습니다.

if(!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("king4k1/seoulsubway")

reconstruct_data() 함수는 이용객 개별에 대한 raw_data 입력 시 패키지에 맞게 가공합니다.

raw_data <- data.tabel::fread(file="")
reconstruct_data(raw_data, colname_list=c("departure","departure_line", "arrival","arrival_line"))

subway_sample

총 5000건의 지하철 경로에 대한 정보를 포함하고 있습니다.

경로에는 1-8호선의 데이터만 고려합니다.

library(seoulsubway)
data("subway_sample")

시간대 별 역 하차객수 확인

subway_count <- subway_sample %>% group_by(Time, down_Name) %>% summarise(N=n())

# 4개의 역에 대한 결과 (예시)
subway_count <- filter(subway_count, down_Name%in%c("강남","혜화","시청", "서울"))

ggplot(subway_count, aes(x=Time, y=N, col=down_Name)) + 
geom_line(position = 'jitter') + theme(legend.position="bottom")

shortestpath() 함수는 지하철 최단거리를 제공합니다.

총 13개의 노선(1-9호선과 신분당선, 분당선, 경의중앙선, 우이신설선)이 포함되어 있습니다.

ex1. 먹골 -> 혜화

shortestpath(departure="먹골", arrival = "혜화", max_route = 1)

shortestpath_plot(departure = "먹골", arrival = "혜화", google_key = private_key, zoom = 13)

ex2. 태릉입구 -> 혜화

shortestpath_plot(departure = "태릉입구", arrival = "혜화", google_key = private_key, zoom = 13)

ex3. 보문 -> 서울

shortestpath_plot(departure = "보문", arrival = "서울", google_key = private_key, zoom = 13)

get_total_count() 함수는 모든 경로에 따른 역별 누적 경유회수 출력합니다.

total_count <- get_total_count(dat=subway_sample, departure_name = "up_Name", departure_line_name = "up_Line", arrival_name = "down_Name", arrival_line_name = "down_Line")

total_count_upper500 <- total_count[which(total_count$count>=500), ]
ggplot(data=total_count_upper500, aes(x=station, y=count, fill = station)) + geom_bar(stat="identity") +  theme(axis.text.x=element_text(angle=90, face="bold")) + theme(legend.position="none")

congestion_plot() 함수를 통하여 서울지도 내 지하철 혼잡도 시각화가 가능합니다.

congestion_plot(input_data=data_str_example, 
                center=c(126.97796919, 37.566535), zoom=11,
                google_key = API_key)


king4k1/seoulsubway documentation built on Nov. 18, 2019, 3:38 p.m.