How to export lintr output to a file?

464 views Asked by At

I am writing some scripts in R and our standard is use lintr for standardization of the code. Please advice how can I export the output of the lint function to a txt file for example. Thanks in advance!

2

There are 2 answers

0
fmic_ On BEST ANSWER

You can use the capture.output() function:

capture.output(lint("myscript.R"), file="lint_output.txt)
0
Goerman On

Another option is to convert the result in a dataframe and then save it in csv format.

result <- lintr::lint("my_script.R")
df <- as.data.frame(result)
write.csv(df, file="output_file_name.csv")