当使用edit()查看矩阵或数据框时,我经常遇到R的突然崩溃,从而导致新的 session 。我无法识别任何系统性:有时在打开单独的编辑窗口时会崩溃,而在查看或关闭窗口时又会崩溃。要查看的对象的大小似乎也不重要。此功能是否存在已知的固有不稳定性?如果是,是否与某些软件包不兼容相关?第三:是否有替代方法(View()除外)到edit()?
最佳答案
我正在使用最新的Windows 7和基本R-3.0.2。这是getOption(“editor”):
功能(名称,文件,标题){
# use internal editor for files and functions, otherwise
# delegate to the default editor
if (is.null(name) || is.function(name)) {
# if no name then use file
if (is.null(name)) {
if (!is.null(file) && nzchar(file))
targetFile <- file
else
targetFile <- scratchFile
}
# otherwise it's a function, write it to a file for editing
else {
functionSrc <- .rs.deparseFunction(name, TRUE)
targetFile <- scratchFile
writeLines(functionSrc, targetFile)
}
# invoke the RStudio editor on the file
if (.Call("rs_editFile", targetFile)) {
# try to parse it back in
newFunc <- try(eval.parent(parse(targetFile)),
silent = TRUE)
if (inherits(newFunc, "try-error")) {
stop(newFunc, "You can attempt to correct the error using ",
title, " = edit()")
}
return(newFunc)
}
else {
stop("Error occurred while editing function '", name, "'")
}
}
else
edit(name, file, title, editor=defaultEditor)
}