R 防禦式程式設計
Dr. Colin Gillespie
Jumping Rivers
類似拼字檢查的運作方式
使用 lintr
lint() 函式假設有以下程式碼:
my_bad<-function(x, y) {
x+y
}
存於檔案 code.R。
lintr::lint("code.R") 會標示兩個問題my_bad<-function(x,y) {
x+y
}
r[[1]]
tmp.R:1:7: style: Put spaces around all infix operators.
my_bad<-function(x,y) {
~^~~
my_bad <- function()
my_bad<-function(x,y) {
x+y
}
r[[3]]
tmp.R:2:4: style: Put spaces around all infix operators.
x+y
~^~
x + y
R 防禦式程式設計