Assad, although I think the actual answer to the question is in the comments, let me suggest this template as a broader solution:
rm(list= Filter( Negate(is.na), # filter entries corresponding to objects that don't meet function criteria sapply( ls(pattern="^a"), # only objects that start with "a" function(x) if(is.matrix(get(x))) x else NA # return names of matrix objects ) ) )
In this case, I delete the entire matrix object starting with "a". sapply modifying the pattern argument and the function used by sapply here, you can get fine control over what you delete without specifying a lot of names.
If you are concerned that this might delete something that you do not want to delete, you can save the result of the Filter(... operation Filter(... in a variable, view the contents and then run the rm(list=...) command.
BrodieG Feb 10 '14 at 13:23 2014-02-10 13:23
source share