[R] removing last element from a character string
Kjetil Brinchmann Halvorsen
kjetil at acelerate.com
Sat Aug 21 00:17:48 CEST 2004
> test <- "xyz"
> nchar(test)
[1] 3
> n <- nchar(test)
> n <- n-1
> substr(test,1,n)
[1] "xy"
Kjetil Halvorsen
Luis Rideau Cruz wrote:
>R-help,
>
>Any function to remove last element (or any specific elemnet in the sequence) from a character string?
>
>t<-c("aaab","qqqc")
>
>
>
>>function(t) ### remove last character (b and c respectively)
>>
>>
>
>
>
>>aaa qqq
>>
>>
>
>Thanks
>
>`·._ .· `·. _ .· `·._ .· `·. _ .· `·._ .· `·. _ .· `·..
>Luis Ridao Cruz
>Fiskirannsóknarstovan
>Nóatún 1
>P.O. Box 3051
>FR-110 Tórshavn
>Faroe Islands
>Phone: +298 353900
>Phone(direct): +298 353912
>Mobile: +298 580800
>Fax: +298 353901
>E-mail: luisr at frs.fo
>Web: www.frs.fo
>
>`·._ .· `·. _ .· `·._ .· `·. _ .· `·._ .· `·. _ .· `·..
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
>
>
More information about the R-help
mailing list