Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Apply a text mining function to every data frame within a list of data frames by using a for loop?

I have a list of dataframes and I would like to apply a text mining command (namely removing punctuation) to every dataframe within my list of dataframes. Since I have more than 1k dataframes/documents within my list I should do it with a for loop/apply function.

   library("tm")
    
    corpus$df_19970207 <- tm_map(corpus$df_19970207, removePunctuation)
    corpus$df_19970310 <- tm_map(corpus$df_19970310, removePunctuation)

… and so on.

corpus would be my list of data frames and df_xxx the respective data frame.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What would be the easiest way to do this?
I know I did not provide a repex but I feel like my question is so trivial..

Many thanks in advance!

>Solution :

We may use lapply

corpus2 <- lapply(corpus, function(x) tmp_map(x, removePunctuation))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading