2016-07-12 3 views
1

저는 R 프로젝트와 함께 손을 더럽 히고 있습니다.텍스트 마이닝 R : 서브 사용

첫 번째 부분에서는 벡터 msg의 데이터를 정리하려고합니다. 그러나 나중에 termdocumentmatrix을 만들면 이러한 문자가 계속 표시됩니다. 변수는 나중에 사용과 같이 코드의 첫 두 줄을 저장하지 않은

gsub("\\b\\w{1,4}\\b ", " ", pclbyshares$msg) 
gsub("[[:punct:]]", "", pclbyshares$msg) 
corpus <- Corpus(VectorSource(pclbyshares$msg)) 
TermDocumentMatrix(corpus) 
tdm <- TermDocumentMatrix(corpus) 
findFreqTerms(tdm, lowfreq=120, highfreq=Inf) 
+1

가'에서보세요 재현 예를 – akrun

+0

를 제공하세요 tm_map'와'content_transformer' –

답변

0

나는 문장 미만의 4 글자와 단어를 제거하고 제거 할 것이다. 따라서 귀하의 corpus 변수를 작성하는 세 번째 행에서 수정되지 않은 msg 데이터를 사용하고 있습니다. 이 시도 보내기?

msg_clean <- gsub("\\b\\w{1,4}\\b ", " ", pclbyshares$msg) 
msg_clean <- gsub("[[:punct:]]", "", msg_clean) 
corpus <- Corpus(VectorSource(msg_clean)) 
TermDocumentMatrix(corpus) 
tdm <- TermDocumentMatrix(corpus) 
findFreqTerms(tdm, lowfreq = 120, highfreq = Inf) 
+0

이 후 의도 한대로 – Claudio

+0

는'볼 msg_clean' 않습니다 아직 문장 부호를 제거하지 않는 것? 위의 처음 두 줄은 실행됩니까? –

관련 문제