[R] Removing colon from numerical data
Henrique Dallazuanna
wwwhsd at gmail.com
Thu Mar 4 20:08:23 CET 2010
Try this:
D <- as.numeric(gsub("[[:punct:]]", "", D))
On Thu, Mar 4, 2010 at 2:12 PM, LCOG1 <jroll at lcog.org> wrote:
>
> Basic question, looked through the forum and documentation but didnt see a
> solution.
>
> So consider
>
> O<-c(1:20)
> D<-c("1:","2:","3:","4:","5:","6:","7:","8:","9:","10:","11:","12:","13:","14:","15:","16:",
> "17:","18:","19:","20:")
> Time<-c(51:70)
>
> AveTT<-data.frame(O,D,Time)
>
>
> I would like to remove the colon from the "D" column's data. This is how
> the data is being given to me and its too big to put into excel to remove
> the colons. I tried the below but neither returns what i want.
>
> AveTT$D<-as.numeric(AveTT$D)
>
> AveTT$D<-substr(AveTT$D,1,nchar(AveTT$D)-1)
>
> so i want
> O D Time
> 1 1 1: 51
> 2 2 2: 52
> 3 3 3: 53
> 4 4 4: 54
> 5 5 5: 55
> 6 6 6: 56
> 7 7 7: 57
> 8 8 8: 58
> 9 9 9: 59
> 10 10 10: 60
>
> to become
>
> O D Time
> 1 1 1 51
> 2 2 2 52
> 3 3 3 53
> 4 4 4 54
> 5 5 5 55
> 6 6 6 56
> 7 7 7 57
> 8 8 8 58
> 9 9 9 59
> 10 10 10 60
>
> while maintaining the data's integrity. Thanks
>
> JR
>
> --
> View this message in context: http://n4.nabble.com/Removing-colon-from-numerical-data-tp1578397p1578397.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list