Re: [R] string processing(regular expressions)

2013-09-01 Thread arun
ot;,"C"),function(x) paste0(levels(nCourse),x)),stringsAsFactors=FALSE),c("B","P","C")) head(res) #    B   P   C #1 2AB 2AP 2AC #2 2BB 2BP 2BC #3 2CB 2CP 2CC #4 7AB 7AP 7AC #5 7BB 7BP 7BC #6 7CB 7CP 7CC A.K. - Original Message - From: Robert Lynch To: R hel

Re: [R] string processing(regular expressions)

2013-09-01 Thread Rui Barradas
Hello, Try the following. gsub("^0+", "", as.character(nCourse)) Hope this helps, Rui Barradas Em 01-09-2013 21:41, Robert Lynch escreveu: I have a variable that is course # nCourse <- as.factor(c("002A","002B","002C","007A","007B","007C","101","118A","118B","118C")) And I would like to ge

[R] string processing(regular expressions)

2013-09-01 Thread Robert Lynch
I have a variable that is course # nCourse <- as.factor(c("002A","002B","002C","007A","007B","007C","101","118A","118B","118C")) And I would like to get rid of the leading zeros, and have the following set ("2A","2B","2C","7A","7B","7C","101","118A","118B","118C") to paste() together with the depa