Vote count:
1
I'm using the 'tm' package to clean and mine a large set of social media posts related to e-cigarettes as a precursor to running principle components analysis on the output to identify key themes. I have removed punctuation which results in a lot of 'e cig' and 'e liquid' references that I need to combine to become 'ecig' and 'eliquid.'
Am having a hard time formulating a function that runs consistently. This worked when I was dealing with just a subsample (n=40) of the posts:
fun6 <- function(x) {gsub("e cig","ecig",x)}
tmp1 <- tm_map(tmp, content_transformer(fun6), lazy=TRUE)
However, I'm now trying to run the transformations on a larger file (n=100,000+ posts) and it's not working. I run it, inspect, and don't see any modifications. I've tried a lot of iterations using regex but can't get anything to work.
(I should also mention that if I run all of my code at one time with the larger sample, TM breaks, despite working fine with the subsample. I'm trying to figure out where that happens by running line-by-line… so will probably have another post about that later).
Any thoughts / guidance appreciated!
How to remove whitespace between two specific letters in TM pkg using gsub
Aucun commentaire:
Enregistrer un commentaire