Reputation: 11
I am still learning to use Statistical softwares and I have a question about R. I downloaded R and RStudio. I have a data table which has one column with 5571 codes, one code in each line. Each code has 7 digits and I need to delete the last digit of each code. I want to know if I can do this in an easy way using the software R and how, because it is almost impossible to delete each number manually. Please, I would appreciate if someone could help me telling how to do it or if there is another software that I could use.
Upvotes: 0
Views: 136
Reputation: 4220
This is a programming question not statistics, post in stack overflow. But you can look at
> x <- 101:110
> x
[1] 101 102 103 104 105 106 107 108 109 110
> floor(x/10)
[1] 10 10 10 10 10 10 10 10 10 11
or
> as.numeric(sub(".$","",x))
[1] 10 10 10 10 10 10 10 10 10 11
or based off @generic_user's comment (numbers all need to be same length)
> as.numeric(substr(x,start=1,stop=2))
[1] 10 10 10 10 10 10 10 10 10 11
Upvotes: 3