Is there an r code I can use that will remove all of the comments from an .r file?
Asked
Active
Viewed 558 times
1 Answers
10
See tidy.source()
in the formatR package, option keep.comment = FALSE
And an example.... copy and paste the following (including the comment). Tidy source defaults to reading the clipboard for the code.
# This is a useless comment
for(i in 1:5){
print(i)
}
and then
> library(formatR)
> tidy.source(keep.comment = FALSE)
for (i in 1:5) {
print(i)
}

Rguy
- 1,622
- 1
- 15
- 20