How to hide and call an element of a list in R? -


suppose have r list:

ls<-list(a="a",b="b",c="c") 

is there way can hide element b? such like:

> ls $a [1] "a"  $c [1] "c" 

and if it's hidden, how call ls$b or ls$.b? asking because element b may large , don't want list out used next analysis.

you can specify new class , new print function objet :

x <- vector("list", 3l) names(x) <- letters[1:3] x[[1]] <- 1 x[[2]] <- "the element hide" x[[3]] <- "a" class(x) <- c("bob", "list") attr(x, "hidden") <- "b" print.bob <- function (x) {     hid <- attr(x, "hidden")     print(x[!names(x) %in% hid])     } x $a [1] 2  $c [1] 4 # length(x) [1] 3 

hth


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -