I'm new to this, so I'm sorry if this is a stupid question... I need help with a bit of code in R...
I have a bit of code (below) which puts a space around all my punctuation in all txt files in a folder. It's lovely, but I don't want it to add space around apostrophes (') -
Can anybody help me exclude apostrophes in that bit gsub("(\.+|[[:punct:]])", " \1 " ---? Or is that how you would do it? (with [^ ?)
I get this: "I want : spaces around all these marks ; : ! ? . but i didn ’ t want it there in didn ’ t"
I want this: "I want : spaces around all these marks ; : ! ? . but i didn’t want it there in didn’t"
for(file in filelist){
tx=readLines(file)
tx2=gsub("(\\.+|[[:punct:]])", " \\1 ", tx)
writeLines(tx2, con=file)
}