当使用edit()查看矩阵或数据框时,我经常遇到R突然崩溃,导致新的会话。我没有认识到任何系统性:有时它会在打开单独的编辑窗口时崩溃,在查看或关闭它时会再次崩溃。要查看的对象的大小似乎也不重要。这个函数有固有的不稳定性吗?如果是,是否与某些包不兼容性相关?第三:是否有替代(除了View())以编辑()?
答案 0 :(得分:0)
我正在使用最新的Windows 7和基础R-3.0.2。这是getOption(“编辑”):
功能(名称,档案,标题){
# 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)
}