我有一个用户定义的R函数来编写算法的输出。为了简化一切,它看起来如下:
writeMyOutput <- function (fileName="myOutput.txt"){
fileConn <- file(fileName)
method <- "BFGS"
nIter <- "Num of Iter is 70"
msg <- "Successful convergence"
writeLines(c(method, nIter, msg), fileConn, sep = "\n")
close(fileConn)
estimates <- data.frame(matrix(rep(1:8), nrow =2, ncol=4))
write.table(estimates, file=fileName, append=TRUE, row.names= F, quote = F) }
当我调用此函数时,它给出了write.table()append命令
的以下警告enter Warning message:In write.table(estimates, file = fileName, append = TRUE, row.names = F, :appending column names to filecode here
我想知道如何抑制特定用户定义函数的警告。如果有人可以提供任何帮助,请欣赏。