How can I delete multiple values from a vector in R?

0 votes
Apr 26, 2018 in Data Analytics by zombie
• 3,690 points
51 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
The %in% operator tells  which elements are among the numers to be removed:

m <- sample (1 : 10)
remove <- c (3, 5)
m
[1] 10  5  2  7  1  6  3  4  8  9
m %in% remove
[1] FALSE  TRUE  FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
m [! m %in% remove]
[1] 10 2 7  1  6  4  8  9
answered Apr 26, 2018 by shams
• 3,580 points

Related Questions In Data Analytics

0 votes
2 answers

How to remove NA values from a Vector in R?

data = data[!is.na(data)]\ READ MORE

answered Apr 5 in Data Analytics by anonymous
3,484 views
0 votes
1 answer

How can we count TRUE values in a logical vector?

In the cases of problems where logical ...READ MORE

answered Apr 19, 2018 in Data Analytics by zombie
• 3,690 points
355 views
0 votes
1 answer

How can I select a CRAN mirror in R ?

There are many ways of doing so ...READ MORE

answered May 9, 2018 in Data Analytics by zombie
• 3,690 points
21 views
0 votes
1 answer

How can I Split code over multiple lines in an R script?

You can do this as follows: setwd(paste("~/a/very/long/path/here ...READ MORE

answered May 21, 2018 in Data Analytics by zombie
• 3,690 points
74 views
0 votes
1 answer

How can I find file name from full file path in R?

You can use: basename("C:/some_dir/filename.ext") # [1] "filename.e ...READ MORE

answered May 24, 2018 in Data Analytics by zombie
• 3,690 points
11 views
0 votes
1 answer

How can I read a .csv file in R language?

read.csv () function is used to read ...READ MORE

answered Jun 11, 2018 in Data Analytics by zombie
• 3,690 points
17 views
0 votes
1 answer

How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

answered Jul 4, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
53 views
0 votes
1 answer

How can I import a file in R without giving the destination/file path to the specified file?

You can use the window explorer to ...READ MORE

answered Aug 28, 2018 in Data Analytics by ANMOL
• 3,620 points

edited Aug 28, 2018 by Vardhan 23 views
0 votes
1 answer

How can I convert a factor variable to numeric in R ?

A factor variable can be converted to ...READ MORE

answered Sep 18, 2018 in Data Analytics by shams
• 3,580 points
20 views
0 votes
1 answer

How can I define Global Variables in R?

The variables declared inside a function are ...READ MORE

answered Apr 25, 2018 in Data Analytics by shams
• 3,580 points
538 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.