Getting rid of extra periods - cleaning data using R

0 votes

I have the following data

1) 100      |  101.25  | 102.25. | .   | .. | 201.5. |
2) 200.05.  |  200.56. | 205     | ..  | .  | 3000   |
3) 300.98   |  300.26. | 2001.56.| ... | 0.2| 5.65.  |

Expected output

1) 100   | 101.25   | 102.25  |NA | NA |201.5
2) 200.05|200.26    | 205     |NA | NA |3000
3) 300.98|300.26    |2001.26  |NA |0.2 |5.65
Nov 13, 2018 in Data Analytics by Ali
• 10,670 points
54 views

1 answer to this question.

0 votes

Just try removing the periods using sub function 

x <- c("101.25", "200.56.", "300.26")
x <- sub("\\.$", "", x)
answered Nov 13, 2018 by Maverick
• 10,820 points

Related Questions In Data Analytics

0 votes
1 answer

How to forecast season and trend of data using STL and ARIMA in R?

You can use the forecast.stl function for the ...READ MORE

answered May 18, 2018 in Data Analytics by DataKing99
• 8,150 points
826 views
0 votes
2 answers

what are the different ways of getting/reading data into for cleaning

Most used functions for reading or extracting ...READ MORE

answered Aug 22, 2019 in Data Analytics by anonymous
• 32,460 points
55 views
0 votes
2 answers

How to change the value of a variable using R programming in a data frame?

You are getting this error since the ...READ MORE

answered Aug 16, 2019 in Data Analytics by anonymous
• 32,460 points
6,648 views
0 votes
1 answer
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,820 points
427 views
0 votes
1 answer

Cleaning a Data Frame Using Regexp in R

The simplest way: library(dplyr) library(stringi) df %>% mutate(NUMERO_APPEL.fix = ...READ MORE

answered Nov 13, 2018 in Data Analytics by Maverick
• 10,820 points
50 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,820 points
134 views
0 votes
1 answer

Manipulate character string using gsub() and perform multivariate data cleaning efficiently in R

gsubfn is perfect for this task: library(gsubfn) as.vector(sapply(gsubfn("[A-Z]", list(B="* 1", ...READ MORE

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

Cleaning data using R

Try something like this: text1='"id","gender","age","category1","category2","category3","category4","category5","category6","category7","category8","category9","category10" 1,"Male",22,"movies","music","travel","cloths","grocery",,,,, 2,"Male",28,"travel","books","movies",,,,,,, 3,"Female",27,"rent","fuel","grocery","cloths",,,,,, 4,"Female",22,"rent","grocery","travel","movies","cloths",,,,, 5,"Female",22,"rent","online-shopping","utiliy",,,,,,,' d1 <- read.table(text=text1, sep=",", ...READ MORE

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

Clean a set of data using R

Try this: NCM <- c(5,1,3,2,4) Mbrand <- c(1,5,3,4,2) fac<-factor(Mbrand, levels ...READ MORE

answered Nov 13, 2018 in Data Analytics by Maverick
• 10,820 points
81 views