単なるメモですが、
rm(list=subset(ls(), !(ls() %in% c('hoge', 'hage'))))
rm(list=ls()[-which(ls() %in% c('hoge', 'hage'))])
'hoge', 'hage'のところに、消したくないオブジェクト名を書いておく。
後者のほうが2文字短い。
単なるメモですが、
rm(list=subset(ls(), !(ls() %in% c('hoge', 'hage'))))
rm(list=ls()[-which(ls() %in% c('hoge', 'hage'))])
'hoge', 'hage'のところに、消したくないオブジェクト名を書いておく。
後者のほうが2文字短い。