How to remove certain character from a vector

0 votes

I have a vector which looks something like this, c(61,33,"67*",98,"32*", "73*"). I need to clean the data using R by transforming this into a vector without the extra *. The result in this example should be c(61,33,67,98,32,73).

Nov 14, 2018 in Data Analytics by Ali
• 10,450 points
41 views

1 answer to this question.

0 votes

We can use sub to remove the * by specifying fixed = TRUE as it is a metacharacter that denotes zero or more characters.

answered Nov 14, 2018 by Maverick
• 10,040 points

Related Questions In Data Analytics

0 votes
4 answers

How to remove NA values from a Vector in R?

You can try na.omit() or na.exclude() too. ...READ MORE

answered Jul 31 in Data Analytics by anonymous
• 21,430 points
5,405 views
0 votes
1 answer

How to extract specific columns from a DataFrame ?

Yes there are so many ways: df[,c(V2,V4)] and another ...READ MORE

answered Apr 11, 2018 in Data Analytics by DeepCoder786
• 1,700 points
750 views
0 votes
2 answers

How to count the number of elements with the values in a vector?

Use dplyr function group_by(). > n = as.data.frame(num) > ...READ MORE

answered 3 days ago in Data Analytics by anonymous
• 21,430 points
82 views
0 votes
2 answers

How to remove rows with missing values (NAs) in a data frame?

Hi, The below code returns rows without ...READ MORE

answered 4 days ago in Data Analytics by anonymous
• 21,430 points
4,152 views
0 votes
1 answer
0 votes
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered 3 days ago in Data Analytics by anonymous
• 21,430 points
97 views
0 votes
1 answer

Replace comma with a period in data cleaning using R

You can use the scan function in ...READ MORE

answered Nov 13, 2018 in Data Analytics by Maverick
• 10,040 points
40 views
0 votes
1 answer

Look for certain values from not cleaned data

First see what rows meet t$ps04==1 & t$rectyp==1. ...READ MORE

answered Nov 13, 2018 in Data Analytics by Maverick
• 10,040 points
25 views
0 votes
1 answer

How do I remove unnecessary redundant data from a dataset?

You can use dimensionality reduction methods such as ...READ MORE

answered Nov 13, 2018 in Data Analytics by Maverick
• 10,040 points
34 views
0 votes
1 answer

How do i send R errors from console to standard java output?

R offers a command to save its ...READ MORE

answered Nov 8, 2018 in Data Analytics by Maverick
• 10,040 points
18 views