I wrote this to remove all objects apart from functions from the current environment (Programming language used is R with IDE R-Studio):
    remove_list=c()                             # create a vector
      for(i in 1:NROW(ls())){                   # repeat over all objects in environment
        if(class(get(ls()[i]))!="function"){    # if object is *not* a function
         remove_list=c(remove_list,ls()[i])     # ..add to vector remove_list
         }    
      }
    rm(list=remove_list)                        # remove all objects named in remove_list
Notes-
The argument "list" in rm(list=) must be a character vector. 
The name of an object in position i of the current environment is returned from ls()[i] and the object itself from get(ls()[i]). Therefore the class of an object is returned from class(get(ls()[i]))