r : Need content_transformer() called by tm_map() to change non-letters to spaces
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 4 years ago . In the following code, any characters matching "/|@| \|") will be changed to a space. > library(tm) > toSpace <- content_transformer(function(x, pattern) gsub(pattern, " ", x)) > docs <- tm_map(docs, toSpace, "/|@| \\|") What code would transform all non-letters to a space? (What goes where the xxxxx's are below.) It is very difficult to put all non-letters in a string... (Very