r 用于从R中的全局环境中删除项目的函数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r 用于从R中的全局环境中删除项目的函数相关的知识,希望对你有一定的参考价值。
#' Remove everything except functions
#'
#' Remove everything from the global environment except functions
#' @export
rm.except.fn <- function(){
rm(list = setdiff(ls(envir = .GlobalEnv), lsf.str(envir = .GlobalEnv)), envir = .GlobalEnv)
}
#' Remove only functions
#'
#' Remove functions from the global environment
#' @export
rm.fn <- function(){
rm(list=lsf.str(envir = .GlobalEnv), envir = .GlobalEnv)
}
#' Remove everything except...
#'
#' Remove everything from the global environment except named element. No default.
#' @param x Character vector of elements to be kept. No default
#' @export
rm.all.except <- function(x){
x <- c("rm.all.except",x)
rm(list = ls(envir = .GlobalEnv)[!ls(envir = .GlobalEnv) %in% x], envir = .GlobalEnv)
}
以上是关于r 用于从R中的全局环境中删除项目的函数的主要内容,如果未能解决你的问题,请参考以下文章