How to export lintr output to a file?

501 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 best solutions below

0
On BEST ANSWER

You can use the capture.output() function:

capture.output(lint("myscript.R"), file="lint_output.txt)
0
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")