[R] length of a string

Paul Smith phhs80 at gmail.com
Wed Sep 5 16:02:58 CEST 2007


On 9/5/07, João Fadista <Joao.Fadista at agrsci.dk> wrote:
> I would like to know how can I compute the length of a string in a dataframe. Example:
>
> SEQUENCE                               ID
> TGCTCCCATCTCCACGG            HR04FS000000645
> ACTGAACTCCCATCTCCAAT      HR00000595847847
>
> I would like to know how to compute the length of each SEQUENCE.

Maybe the following code?

> data
                    var1 var2
1       This is a string   12
2 This is another string   34
> nchar(data[,1])
[1] 16 22
>

Paul



More information about the R-help mailing list