[감성사전] LIWC R 연동 사용예제

Author : tmlab / Date : 2016. 10. 27. 18:04 / Category : Text Mining/R

#install.packages("devtools")
#devtools::install_github("kbenoit/quanteda")
library(devtools)
library(quanteda)
## quanteda version 0.9.5.23
## 
## Attaching package: 'quanteda'
## The following object is masked from 'package:base':
## 
##     sample
mfdict <- dictionary(file = "http://ow.ly/VMRkL", format = "LIWC") 
## Warning in lapply(catlist[2:ncol(catlist)], as.integer): 강제형변환에 의해
## 생성된 NA 입니다

## Warning in lapply(catlist[2:ncol(catlist)], as.integer): 강제형변환에 의해
## 생성된 NA 입니다
mydfm <- dfm(inaugTexts, dictionary = mfdict)
## 
##    ... lowercasing
##    ... tokenizing
##    ... indexing documents: 57 documents
##    ... indexing features: 9,215 feature types
##    ... applying a dictionary consisting of 11 keys
##    ... created a 57 x 11 sparse dfm
##    ... complete. 
## Elapsed time: 0.87 seconds.
mydfm
## Document-feature matrix of: 57 documents, 11 features.
topfeatures(mydfm, decreasing=TRUE)
##   IngroupVirtue AuthorityVirtue      HarmVirtue  FairnessVirtue 
##            1387            1039             895             567 
##        HarmVice MoralityGeneral     IngroupVice    PurityVirtue 
##             405             319             226              90 
##    FairnessVice   AuthorityVice 
##              88              51
features(mydfm)
##  [1] "HarmVirtue"      "HarmVice"        "FairnessVirtue" 
##  [4] "FairnessVice"    "IngroupVirtue"   "IngroupVice"    
##  [7] "AuthorityVirtue" "AuthorityVice"   "PurityVirtue"   
## [10] "PurityVice"      "MoralityGeneral"
a=as.matrix(mydfm)
b=as.data.frame(a)
sum(b$PurityVice)
## [1] 28


Archives

05-15 23:01

Contact Us

Address
경기도 수원시 영통구 원천동 산5번지 아주대학교 다산관 429호

E-mail
textminings@gmail.com

Phone
031-219-2910

Tags

Calendar

«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Copyright © All Rights Reserved
Designed by CMSFactory.NET