How to restore RStudio Viewer Pane after having setting its viewer option to NULL?

痞子三分冷 提交于 2019-12-03 22:15:51

If you have already set the viewer to NULL without preserving your settings, then you will need to copy the viewer setting from a new rsession, but no need to close your current session.

1.The options(viewer=XXXXX) setting is, in fact, a function, so open a new ression.

2.Then retrieve the viewer function setting and copy the function by doing the following at RStudio console prompt:

op <- options()

op$viewer

function (url, height = NULL) 
{
    if (!is.character(url) || (length(url) != 1)) 
        stop("url must be a single element character vector.", 
            call. = FALSE)
    if (identical(height, "maximize")) 
        height <- -1
    if (!is.null(height) && (!is.numeric(height) || (length(height) != 
        1))) 
        stop("height must be a single element numeric vector or 'maximize'.", 
            call. = FALSE)
    invisible(.Call("rs_viewer", url, height))
}

In order to restore your viewer to default now go to the old rsession (the session you want to restore) and at the console prompt restore the viewer option:

>options(viewer=function (url, height = NULL) 
{
    if (!is.character(url) || (length(url) != 1)) 
        stop("url must be a single element character vector.", 
            call. = FALSE)
    if (identical(height, "maximize")) 
        height <- -1
    if (!is.null(height) && (!is.numeric(height) || (length(height) != 
        1))) 
        stop("height must be a single element numeric vector or 'maximize'.", 
            call. = FALSE)
    invisible(.Call("rs_viewer", url, height))
})

These steps will now fully restore the RStudio Viewer Pane.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!