
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove all objects except one or few in R?
We can use rm remove all or few objects.
Example
< x>-rnorm(100,0.5) < y>-1:100 < z>-rpois(100,5) < a>-rep(1:5,20)
To remove all objects
> rm(list=ls()) ls() character(0)
To remove all except a
> rm(list=setdiff(ls(), "a")) > ls() [1] "a"
To remove all except x and a
> rm(list=ls()[! ls() %in% c("x","a")]) ls() [1] "a" "x"
Advertisements