I built a data that shows all the terms with punctuation and its frequency. Then im supposed to remove the punctuation's from them and check if there is any punctuation remaining.
newpapers1 <- tm_map(newpapers, removePunctuation)
punremove <- function(x){gsub(c('¡'|'¯'),"",x)}
punremove1 <- lapply(newpapers1, punremove)
my.check.func <- function(x){str_extract_all(x, "[[:punct:]]")}
my.check1 <- lapply(newpapers1, my.check.func)
p <- as.data.frame(table(unlist(my.check1)))
p
But I still end up with this special character:
Var1 Freq
1 ¡ 25
Is there a way to write a function to remove all the punctuation's together or a function to remove this?
Edit: Upon checking the documents the punctuation still exists:
> newpapers1[[24]]$content
"This study employs a crosscultural perspective to examine how local audiences perceive and enjoy foreign dramas and how this psychological process differs depending on the cultural distance between the media and the viewing audience Using a convenience sample of young Korean college students this study as predicted by cultural discount theory shows that cultural distance decreases Korean audiences¡¯ perceived identification with dramatic characters which erodes their enjoyment of foreign dramas Unlike cultural discount theory however cultural distance arouses Korean audiences¡¯ perception of novelty which heightens their enjoyment of foreign dramas This study discusses the theoretical and practical implications of these findings as well as their potential limitations"
You can use gsub
to remove the punctuation, like this.
newpapers1 <- tm_map(newpapers, removePunctuation)
my.check.func <- function(x){gsub('[[:punct:]]+','',x)}
my.check1 <- lapply(newpapers1, my.check.func)
p <- as.data.frame(table(unlist(my.check1)))
p
Hope this helps.