In this case, you can use the setdiff function to remove all variables except functions as follows:
rm(list = setdiff(ls(), lsf.str()))
ls() returns the set of objects in the global environment.
lsf.str() returns the set of objects having mode function.
setdiff() is used to find the subset of objects in the global environment not having mode as function.