Last active
June 20, 2019 02:15
-
-
Save mrchypark/c316823c9dbd78eea05f7e2186c8d8e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
library(readxl) | |
library(dplyr) | |
library(tidyr) | |
library(stringr) | |
tem <- read_excel("myCabinetExcelData (2).xls", col_names = F) | |
tem %>% | |
distinct(...1) %>% | |
pull(...1) -> col_order | |
tem %>% | |
mutate( | |
title = str_detect(...1, "제목"), | |
arti_id = cumsum(title) | |
) %>% | |
rename( | |
key = ...1, | |
value = ...2 | |
) %>% | |
select( | |
arti_id, key, value | |
) %>% | |
group_by(arti_id, key) %>% | |
mutate(dup = row_number()) %>% | |
ungroup() %>% | |
mutate(arti_id = str_c(arti_id,"-",dup)) %>% | |
select(-dup) %>% | |
spread(key, value) %>% | |
select( | |
c(arti_id, col_order) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment