data load
데이터는 문재인 대통령 취임사 자료를 가져온 text파일입니다.
#데이터 불러오는 패키지
library('tidyverse')
Warning messages:
1: In strsplit(x, "\n") : input string 1 is invalid in this locale
2: In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
#명사추출에 사용되는 패키지
library('KoNLP')
library(tm)
#워드클라우드 패키지
library(wordcloud2)
#사회관계망 패키지
library(qgraph)
library("visNetwork")
setwd('X:/data')
The working directory was changed to X:/data inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the working directory for notebook chunks.
# Lines=readLines('moon.txt',encoding = 'UTF-8')
Lines=read_lines('moon.txt')
SimplePos09() : 9개의 품사 추출
#딕셔너리 불러오기
useNIADic()
Backup was just finished!
983012 words dictionary was built.
Warning message:
In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
#9개 품사 추출
SimplePos09(c('최대한 친절하게 쓴 R','최대한 친절하게 쓴 R'))
[[1]]
[[1]]$최대한
[1] "최대한/M"
[[1]]$친절하게
[1] "친절/N+하/X+게/E"
[[1]]$쓴
[1] "쓰/P+ㄴ/E"
[[1]]$R
[1] "R/F"
[[2]]
[[2]]$최대한
[1] "최대한/M"
[[2]]$친절하게
[1] "친절/N+하/X+게/E"
[[2]]$쓴
[1] "쓰/P+ㄴ/E"
[[2]]$R
[1] "R/F"
#22개 품사로 추출
mp <- SimplePos22(Lines)
mp <- SimplePos22(Lines)
Warning message:
In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
#명사 추출
temp=str_match(mp,'[ㄱ-힣]+/N')
argument is not an atomic vector; coercing
head(temp)
[,1]
[1,] "북녘/N"
[2,] NA
[3,] "남북군사공동위원회/N"
[4,] NA
[5,] "그동안/N"
[6,] "나/N"
#품사를 제거한 순수 명사 추출
temp=str_match(mp,'([ㄱ-힣]+)/N')
argument is not an atomic vector; coercing
head(temp)
[,1] [,2]
[1,] "북녘/N" "북녘"
[2,] NA NA
[3,] "남북군사공동위원회/N" "남북군사공동위원회"
[4,] NA NA
[5,] "그동안/N" "그동안"
[6,] "나/N" "나"
#명사추출
doc=str_match(mp,'([ㄱ-힣]+)/N')
argument is not an atomic vector; coercingWarning message:
In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
#결측치 제거
doc2=doc[,2]
doc2=doc2[!is.na(doc2)]
#리스트 해제
unique(unlist(extractNoun(Lines)))
[1] "북녘" "동포" "여러분"
[4] "남녘" "국민" "해외"
[7] "전쟁" "한반도" "시작"
[10] "되" "남" "오늘"
[13] "전" "지역" "수"
[16] "위험" "합의" ""
[19] "남북군사공동위원회" "동해" "군사"
[22] "분야" "사항" "이행"
[25] "협의" "진행" "하기"
[28] "1953" "년" "정전협정"
[31] "포성" "65" "우리"
[34] "삶" "계속" "이유"
[37] "목숨" "들이" "이웃"
[40] "들" "사이" "벽"
[43] "평화" "지대" "정상"
[46] "그동안" "위협" "이념"
[49] "대결" "특권" "부패"
[52] "반인권" "사회" "나라"
[55] "복원" "할" "나"
[58] "말씀" "가슴" "처음"
[61] "비핵화" "방안" "의미"
[64] "성과" "북측" "동창"
[67] "리" "엔진" "시험장"
[70] "미사일" "발사대" "유관국"
[73] "전문가" "참여" "하"
[76] "영구적" "폐쇄" "미국"
[79] "상응" "조치" "영변"
[82] "핵시설" "영구" "폐기"
[85] "겨레" "모두" "일"
[88] "완전" "한" "앞"
[91] "등" "국제" "최종"
[94] "달성" "긴밀" "협력"
[97] "해" "역할" "막중"
[100] "신뢰" "때" "절실"
[103] "판문점" "선언" "이후"
[106] "주변" "역사" "적"
[109] "사변" "거대" "변화"
[112] "사상" "최초" "북미"
[115] "회담" "추가" "핵실험"
[118] "실험" "일체" "약속"
[121] "이" "한미" "양국"
[124] "대규모" "연합" "훈련"
[127] "중단" "개성" "남북"
[130] "공동" "연락사무소" "설치"
[133] "상시적" "문제" "논의"
[136] "시대" "꿈" "눈앞"
[139] "번영" "마음" "순간"
[142] "것" "오랫동안" "준비"
[145] "끝" "하나" "8"
[148] "천" "길" "완성"
[151] "내" "실천" "김정은"
[154] "위원장" "평양" "북"
[157] "교류" "증대" "민족"
[160] "경제" "균형적" "발전"
[163] "대책" "올해" "안"
[166] "동·서해선" "철도" "도"
[169] "연결" "착공식" "환경"
[172] "조성" "대" "공단"
[175] "금강산" "관광" "사업"
[178] "정상화" "전염성" "질병"
[181] "유입" "확산" "보건의료"
[184] "추진" "이산가족" "상설"
[187] "면회소" "복구" "왕래"
[190] "화상" "상봉" "우선"
[193] "실현" "2032" "하계올림픽"
[196] "개최" "유치" "3.1운동"
[199] "100" "주년" "행사"
[202] "구체" "10" "월"
[205] "예술단" "서울" "가을"
[208] "공연" "방문" "요청"
[211] "김" "시" "여기"
[214] "말" "특별" "사정"
[217] "최고지도자" "남북관계" "획기적"
[220] "전기" "마련" "핵무기"
[223] "핵" "뜻" "세계"
[226] "여망" "부응" "결단"
[229] "실행" "경의" "표"
[232] "바탕" "대화" "재개"
[235] "친서" "교환" "간"
[238] "확인" "정상회담" "지점"
[241] "노력" "지난봄" "씨앗"
[244] "열매" "감사"
corpus말뭉치 : 텍스트를 모아놓은것
term document matrix : 각 문서에 나타난 단어를 표로 정리한 것
termDocumentMatrix에서 tokenize에 function은 Terms에 해당하는 list를 생성할 함수
removeNumbers는 숫자목록을제거
removePunctuation는 모든 구두점을 제거
stripWhitespacesms 공백을 제거한다.
wordLengths 는 최소 몇글자부터 최대 몇글자까지 할지 최대는 inf 사용 가능
stopwords로 특정 단어 제거 가능
texts <- c('hello world', 'hello text')
Warning message:
In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
# corpus에대한 객체로 변환
cps <- Corpus(VectorSource(texts))
#courpus 확인
inspect(cps[[1]])
<<PlainTextDocument>>
Metadata: 7
Content: chars: 11
hello world
#TermDocumentMatrix 생성
tdm <- TermDocumentMatrix(cps)
as.matrix(tdm)
Docs
Terms 1 2
hello 1 1
world 1 0
text 0 1
#Encoding
texts <- c('hello world', 'hello text')
# corpus에대한 객체로 변환
#한글로 사용하기위해 VCorpus 사용
cps <- VCorpus(VectorSource(Lines))
#TermDocumentMatrix 생성
tdm <- TermDocumentMatrix(cps)
as.matrix(tdm)
Docs
Terms 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
'가까운 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
'가을이 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
'올해 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
100주년 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10월이 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1953년 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2032년 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3.1운동 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
65년 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8천만 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
가까운 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
가까워질 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
가동해 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
가을의 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
감사합니다. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
같이했습니다. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
개성공단과 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
개성에는 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
거대한 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
것이며 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
것입니다. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
겨레와 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
겨레의 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
결단과 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Docs
Terms 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
'가까운 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
'가을이 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
'올해 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
100주년 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
10월이 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
1953년 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2032년 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
3.1운동 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
65년 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8천만 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
가까운 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
가까워질 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
가동해 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
가을의 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
감사합니다. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
같이했습니다. 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
개성공단과 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
개성에는 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
거대한 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
것이며 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
것입니다. 2 0 0 2 0 2 0 0 0 1 0 1 0 0 0 0 1
겨레와 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
겨레의 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
결단과 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
Docs
Terms 38 39 40 41
'가까운 0 0 0 0
'가을이 0 0 0 0
'올해 0 0 0 0
100주년 0 0 0 0
10월이 0 0 0 0
1953년 0 0 0 0
2032년 0 0 0 0
3.1운동 0 0 0 0
65년 0 0 0 0
8천만 0 0 0 0
가까운 0 0 0 0
가까워질 0 0 0 0
가동해 0 0 0 0
가을의 0 0 1 0
감사합니다. 0 0 0 1
같이했습니다. 0 0 0 0
개성공단과 0 0 0 0
개성에는 0 0 0 0
거대한 0 0 0 0
것이며 0 0 0 0
것입니다. 0 0 0 0
겨레와 0 0 0 0
겨레의 0 0 0 0
결단과 0 0 0 0
[ reached getOption("max.print") -- omitted 280 rows ]
#명사 추출
tdm <- TermDocumentMatrix(cps,control = list(tokenize=function(x)unlist(extractNoun(x)),removeNumbers=T
))
Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!
as.matrix(tdm)
Docs
Terms 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
.운동 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
균형적 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
그동안 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
금강산 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
김정은 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
남북관계 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
남북군사공동위원회 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
대규모 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
동·서해선 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
면회소 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
미사일 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0
반인권 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
발사대 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
보건의료 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
비핵화 0 0 0 0 0 0 0 1 0 0 2 0 0 0 0 0 0 0 0 0 1
상시적 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
시험장 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
여러분 3 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0
연락사무소 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
영구적 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
예술단 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
오랫동안 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
위원장 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
유관국 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
Docs
Terms 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
.운동 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
균형적 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
그동안 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
금강산 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
김정은 0 1 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0
남북관계 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0
남북군사공동위원회 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
대규모 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
동·서해선 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
면회소 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
미사일 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
반인권 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
발사대 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
보건의료 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
비핵화 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
상시적 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
시험장 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
여러분 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0
연락사무소 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
영구적 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
예술단 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
오랫동안 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
위원장 0 1 0 0 0 0 0 0 0 0 3 0 1 1 0 0 0 0
유관국 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Docs
Terms 40 41
.운동 0 0
균형적 0 0
그동안 0 0
금강산 0 0
김정은 0 0
남북관계 0 0
남북군사공동위원회 0 0
대규모 0 0
동·서해선 0 0
면회소 0 0
미사일 0 0
반인권 0 0
발사대 0 0
보건의료 0 0
비핵화 0 0
상시적 0 0
시험장 0 0
여러분 0 0
연락사무소 0 0
영구적 0 0
예술단 0 0
오랫동안 0 0
위원장 0 0
유관국 0 0
[ reached getOption("max.print") -- omitted 16 rows ]
Co-occurence Matrix : 두 단어가 얼마나 함께 나타나는지 나타낸 것.
#단어 빈도
tdm.matrix <- as.matrix(tdm)
Warning message:
In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
word.count <- rowSums(tdm.matrix)
word.count
.운동 균형적 그동안 금강산
1 1 1 2
김정은 남북관계 남북군사공동위원회 대규모
4 2 1 1
동·서해선 면회소 미사일 반인권
1 1 2 1
발사대 보건의료 비핵화 상시적
1 1 5 1
시험장 여러분 연락사무소 영구적
1 8 1 1
예술단 오랫동안 위원장 유관국
1 1 6 1
이산가족 전문가 전염성 정상화
1 1 1 1
정상회담 정전협정 지난봄 착공식
1 1 1 1
최고지도자 판문점 하계올림픽 한반도
1 1 1 9
핵무기 핵시설 핵실험 획기적
1 1 1 1
word.order <- order(word.count, decreasing=T)
word.order
[1] 36 18 23 15 5 4 6 11 1 2 3 7 8 9 10 12 13 14 16 17 19 20 21 22
[25] 24 25 26 27 28 29 30 31 32 33 34 35 37 38 39 40
rownames(tdm.matrix)[word.order[1:20]]
[1] "한반도" "여러분" "위원장"
[4] "비핵화" "김정은" "금강산"
[7] "남북관계" "미사일" ".운동"
[10] "균형적" "그동안" "남북군사공동위원회"
[13] "대규모" "동·서해선" "면회소"
[16] "반인권" "발사대" "보건의료"
[19] "상시적" "시험장"
#상위 20개 단어 빈도
freq.words <- tdm.matrix[word.order[1:20], ]
#상위 20개 단어에 대한 Co-occurence Matrix 생성
co.matrix <- freq.words %*% t(freq.words)
tdm.matrix%*% t(tdm.matrix)
Terms
Terms .운동 균형적 그동안 금강산 김정은 남북관계
.운동 1 0 0 0 0 0
균형적 0 1 0 0 1 0
그동안 0 0 1 0 0 0
금강산 0 0 0 2 0 0
김정은 0 1 0 0 4 1
남북관계 0 0 0 0 1 2
남북군사공동위원회 0 0 0 0 0 0
대규모 0 0 0 0 0 0
동·서해선 0 0 0 1 0 0
면회소 0 0 0 1 0 0
미사일 0 0 0 0 0 0
반인권 0 0 1 0 0 0
발사대 0 0 0 0 0 0
보건의료 0 0 0 1 0 0
비핵화 0 0 0 0 1 0
상시적 0 0 0 0 0 0
시험장 0 0 0 0 0 0
여러분 0 0 0 0 3 0
연락사무소 0 0 0 0 0 0
영구적 0 0 0 0 0 0
예술단 0 0 0 0 0 0
오랫동안 0 0 0 0 0 0
위원장 0 1 0 0 6 3
유관국 0 0 0 0 0 0
이산가족 0 0 0 1 0 0
Terms
Terms 남북군사공동위원회 대규모 동·서해선 면회소 미사일
.운동 0 0 0 0 0
균형적 0 0 0 0 0
그동안 0 0 0 0 0
금강산 0 0 1 1 0
김정은 0 0 0 0 0
남북관계 0 0 0 0 0
남북군사공동위원회 1 0 0 0 0
대규모 0 1 0 0 1
동·서해선 0 0 1 0 0
면회소 0 0 0 1 0
미사일 0 1 0 0 2
반인권 0 0 0 0 0
발사대 0 0 0 0 1
보건의료 0 0 0 1 0
비핵화 0 0 0 0 0
상시적 0 0 0 0 0
시험장 0 0 0 0 1
여러분 0 0 0 0 0
연락사무소 0 0 0 0 0
영구적 0 0 0 0 1
예술단 0 0 0 0 0
오랫동안 0 0 0 0 0
위원장 0 0 0 0 0
유관국 0 0 0 0 1
이산가족 0 0 0 1 0
Terms
Terms 반인권 발사대 보건의료 비핵화 상시적 시험장 여러분
.운동 0 0 0 0 0 0 0
균형적 0 0 0 0 0 0 0
그동안 1 0 0 0 0 0 0
금강산 0 0 1 0 0 0 0
김정은 0 0 0 1 0 0 3
남북관계 0 0 0 0 0 0 0
남북군사공동위원회 0 0 0 0 0 0 0
대규모 0 0 0 0 0 0 0
동·서해선 0 0 0 0 0 0 0
면회소 0 0 1 0 0 0 0
미사일 0 1 0 0 0 1 0
반인권 1 0 0 0 0 0 0
발사대 0 1 0 0 0 1 0
보건의료 0 0 1 0 0 0 0
비핵화 0 0 0 7 0 0 3
상시적 0 0 0 0 1 0 0
시험장 0 1 0 0 0 1 0
여러분 0 0 0 3 0 0 22
연락사무소 0 0 0 0 1 0 0
영구적 0 1 0 0 0 1 0
예술단 0 0 0 0 0 0 0
오랫동안 0 0 0 1 0 0 0
위원장 0 0 0 1 0 0 3
유관국 0 1 0 0 0 1 0
이산가족 0 0 1 0 0 0 0
Terms
Terms 연락사무소 영구적 예술단 오랫동안 위원장 유관국
.운동 0 0 0 0 0 0
균형적 0 0 0 0 1 0
그동안 0 0 0 0 0 0
금강산 0 0 0 0 0 0
김정은 0 0 0 0 6 0
남북관계 0 0 0 0 3 0
남북군사공동위원회 0 0 0 0 0 0
대규모 0 0 0 0 0 0
동·서해선 0 0 0 0 0 0
면회소 0 0 0 0 0 0
미사일 0 1 0 0 0 1
반인권 0 0 0 0 0 0
발사대 0 1 0 0 0 1
보건의료 0 0 0 0 0 0
비핵화 0 0 0 1 1 0
상시적 1 0 0 0 0 0
시험장 0 1 0 0 0 1
여러분 0 0 0 0 3 0
연락사무소 1 0 0 0 0 0
영구적 0 1 0 0 0 1
예술단 0 0 1 0 0 0
오랫동안 0 0 0 1 0 0
위원장 0 0 0 0 12 0
유관국 0 1 0 0 0 1
이산가족 0 0 0 0 0 0
Terms
Terms 이산가족 전문가 전염성 정상화 정상회담 정전협정 지난봄
.운동 0 0 0 0 0 0 0
균형적 0 0 0 0 0 0 0
그동안 0 0 0 0 0 0 0
금강산 1 0 1 1 0 0 0
김정은 0 0 0 0 0 0 0
남북관계 0 0 0 0 0 0 0
남북군사공동위원회 0 0 0 0 0 1 0
대규모 0 0 0 0 0 0 0
동·서해선 0 0 0 1 0 0 0
면회소 1 0 1 0 0 0 0
미사일 0 1 0 0 0 0 0
반인권 0 0 0 0 0 0 0
발사대 0 1 0 0 0 0 0
보건의료 1 0 1 0 0 0 0
비핵화 0 0 0 0 0 0 0
상시적 0 0 0 0 0 0 0
시험장 0 1 0 0 0 0 0
여러분 0 0 0 0 0 0 0
연락사무소 0 0 0 0 0 0 0
영구적 0 1 0 0 0 0 0
예술단 0 0 0 0 0 0 0
오랫동안 0 0 0 0 0 0 0
위원장 0 0 0 0 0 0 0
유관국 0 1 0 0 0 0 0
이산가족 1 0 1 0 0 0 0
Terms
Terms 착공식 최고지도자 판문점 하계올림픽 한반도 핵무기
.운동 0 0 0 0 0 0
균형적 0 0 0 0 0 0
그동안 0 0 0 0 0 0
금강산 1 0 0 0 1 0
김정은 0 1 0 0 2 1
남북관계 0 1 0 0 0 0
남북군사공동위원회 0 0 0 0 1 0
대규모 0 0 0 0 0 0
동·서해선 1 0 0 0 0 0
면회소 0 0 0 0 1 0
미사일 0 0 0 0 0 0
반인권 0 0 0 0 0 0
발사대 0 0 0 0 0 0
보건의료 0 0 0 0 1 0
비핵화 0 0 0 0 4 1
상시적 0 0 0 0 0 0
시험장 0 0 0 0 0 0
여러분 0 0 2 0 14 3
연락사무소 0 0 0 0 0 0
영구적 0 0 0 0 0 0
예술단 0 0 0 0 0 0
오랫동안 0 0 0 0 0 0
위원장 0 3 0 0 2 1
유관국 0 0 0 0 0 0
이산가족 0 0 0 0 1 0
Terms
Terms 핵시설 핵실험 획기적
.운동 0 0 0
균형적 0 0 0
그동안 0 0 0
금강산 0 0 0
김정은 0 0 1
남북관계 0 0 1
남북군사공동위원회 0 0 0
대규모 0 1 0
동·서해선 0 0 0
면회소 0 0 0
미사일 1 1 0
반인권 0 0 0
발사대 1 0 0
보건의료 0 0 0
비핵화 0 0 0
상시적 0 0 0
시험장 1 0 0
여러분 0 0 0
연락사무소 0 0 0
영구적 1 0 0
예술단 0 0 0
오랫동안 0 0 0
위원장 0 0 3
유관국 1 0 0
이산가족 0 0 0
[ reached getOption("max.print") -- omitted 15 rows ]
문서의 키워드나 개념을 직관적으로 파악할 수 있도록 시각화하는 기법
cps <- VCorpus(VectorSource(Lines))
Warning message:
In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
#TermDocumentMatrix 생성
tdm <- TermDocumentMatrix(cps)
#단어 빈도
tdm.matrix <- as.matrix(tdm)
word.count <- rowSums(tdm.matrix)
head(word.count)
'가까운 '가을이 '올해 100주년 10월이 1953년
1 1 1 1 1 1
#명사 추출
tdm <- TermDocumentMatrix(cps,control = list(tokenize=function(x)unlist(extractNoun(x)),removeNumbers=T
))
Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!Input must be legitimate character!
head(names(word.count),3)
[1] "'가까운" "'가을이" "'올해"
head(word.count,3)
'가까운 '가을이 '올해
1 1 1
#워드클라우드 생성
wordcloud2(data.frame(names=names(word.count),freq=word.count))
참고:맥이용자는 par(family=‘AppleGothic’) 설정 해야합니다.
사회관계망(Social network Analysis) 그리기
사회 연결망 데이터를 활용하여 사회 연결망과 사회 구조등을 사회과학적으로 분석하는 하나의 방식
사회관계망 추천 링크
http://ducj2.iptime.org:3838/Competition2/
http://ducj2.iptime.org:3838/Competition1/
http://ducj2.iptime.org:3838/kma/