R/change.R

change <- function (x, verbose = TRUE) 
{
    tf <- ifelse(regexpr("Mydata", search()) == -1, F, T)
    if (any(tf)) {
        pos <- (1:length(search()))[tf]
        detach(pos = pos)
    }
    if(verbose) {
       if (is.data.frame(x)) 
           cat("\nA data frame of size (", nrow(x), ", ", ncol(x), ") has been attached in position 2.\n\n", sep = "")
       else {
           cat("\nAn object with the following structure has been attached in position 2:\n\n", sep = "")
           str(x)
           cat("\n")
       }
    }
    attach(x, 2, paste("Mydata:", substring(deparse(substitute(x))[1], 
        1, 30), sep = ""))
}
John-R-Wallace/R-ToolBox documentation built on April 22, 2024, 8:29 p.m.