I would like transform this line code :
rm(list=ls(all=TRUE)[sapply(mget(ls(all=TRUE)), class) == "data.frame"])
to apply for all data.frame and tbl_df
thanks in advance.
I would like transform this line code :
rm(list=ls(all=TRUE)[sapply(mget(ls(all=TRUE)), class) == "data.frame"])
to apply for all data.frame and tbl_df
thanks in advance.
Kind of ugly, but I think this works.
rm(list=ls(all=TRUE)[sapply(sapply(mget(ls(all=TRUE)), class), function(x) "data.frame" %in% x)])
When you do class(my_tibble) it gives you c("tbl_df", "tbl", "data.frame"). So the output you get from the first sapply() above gives you a list of vectors, which you can sapply() over a second time.
Although it may be easier to just restart your R session.