Removing all objects from work-space except one - R

0 votes

These are the list of objects in my work-space:

ls()
[1] "num1" "num2" "num3" "num4" "num5"

I would want to remove all the objects from the work-space except 'num1'

May 17, 2018 in Data Analytics by nirvana
• 3,060 points
76 views

1 answer to this question.

0 votes

You can use the 'keep()' function from the 'gdata' package:

library(gdata)

The below command will show you which objects will be removed:

> keep(num1)
[1] "num2" "num3" "num4" "num5"

To remove those objects, you need to add sure=TRUE

keep(num1,sure = TRUE)
ls()
[1] "num1"
answered May 17, 2018 by Bharani
• 4,550 points

Related Questions In Data Analytics

0 votes
1 answer

How to remove all variables except functions in R?

One line that removes all objects except for functions: rm(list ...READ MORE

answered Apr 24, 2018 in Data Analytics by DeepCoder786
• 1,700 points
153 views
0 votes
1 answer

Removing outliers from a box-plot - ggplot2 - R

You just have to add 'outlier.shape=NA' inside ...READ MORE

answered May 31, 2018 in Data Analytics by Bharani
• 4,550 points
2,770 views
0 votes
1 answer

Dynamically select element from a list and work with it - Shiny R

Follow these steps: Import the data into R Check ...READ MORE

answered Dec 5, 2018 in Data Analytics by Maverick
• 10,040 points
537 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
93 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
109 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,700 points
75 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,700 points
68 views
0 votes
1 answer

Deleting particular objects from workspace - R

You can use the rm() function to ...READ MORE

answered May 7, 2018 in Data Analytics by Bharani
• 4,550 points
35 views
0 votes
1 answer

Removing all white-spaces from a string

You can use the 'str_replace_all()' function from ...READ MORE

answered May 16, 2018 in Data Analytics by Bharani
• 4,550 points
27 views