私はこれを行う場合、それは実際に、それをプリントアウトされると思う:
library(shiny)
validate(need(try(sd <- read.csv(file = "mtcars1.csv",
stringsAsFactors = FALSE)),
Error reading the file !!!"))
は降伏:
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'mtcars1.csv': No such file or directory
Error: Error reading the file !!!
を私はこれを得る - あなたのメッセージは、最後の行にある注意してください。
あなたはこのようなsupressWarnings
で警告を抑制することができます得
library(shiny)
suppressWarnings(
+ validate(need(try(sd <- read.csv(file = "mtcars1.csv",
stringsAsFactors = FALSE)),
"Error reading the file !!!!")))
:
Error in file(file, "rt") : cannot open the connection
Error: Error reading the file !!!!
それとも、(代わりにtry
のtryCatch
を使用しています)これであなたのメッセージ以外のすべてをSUPRESSことができた:
library(shiny)
suppressWarnings(
validate(need(tryCatch(sd <- read.csv(file = "mtcars1.csv",
stringsAsFactors = FALSE), error=function (e){}),
"Error reading the file !!!!")))
Error: Error reading the file !!!
ありがとうございました。私は自分のエラーがcsvファイルを読むことに関連するものではないと思う。はい、うまくいくはずです。 – athlonshi