As long as you keep in mind Prof. Ripley's comment, you're going to
be fine with nchar().
http://tolstoy.newcastle.edu.au/R/e2/devel/07/05/3450.html
Remember that what you want exactly is given by nchar(obj,
type="chars"), which is **NOT** the default on R 2.5.1 (only on
R-2.6.0).
In your
On 05-Sep-07 13:50:57, João Fadista wrote:
> Dear all,
>
> I would like to know how can I compute the length of a string in a
> dataframe. Example:
>
> SEQUENCE ID
> TGCTCCCATCTCCACGGHR04FS00645
> ACTGAACTCCCATCTCCAAT HR0595847847
>
> I w
Hi,
sapply(levels(df[,"SEQUENCE"]), nchar)
Where 'df' is your data.frame
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
On 05/09/07, João Fadista <[EMAIL PROTECTED]> wrote:
>
> Dear all,
>
> I would like to know how can I compute the length of a string in a
> datafr
On 9/5/07, João Fadista <[EMAIL PROTECTED]> wrote:
> I would like to know how can I compute the length of a string in a dataframe.
> Example:
>
> SEQUENCE ID
> TGCTCCCATCTCCACGGHR04FS00645
> ACTGAACTCCCATCTCCAAT HR0595847847
>
> I would like t
João Fadista wrote:
> Dear all,
>
> I would like to know how can I compute the length of a string in a dataframe.
> Example:
>
> SEQUENCE ID
> TGCTCCCATCTCCACGGHR04FS00645
> ACTGAACTCCCATCTCCAAT HR0595847847
>
> I would like to know how
How's this?
> x = data.frame(ID=c("asdf","asdfasdf"),1:2)
> x
ID X1.2
1 asdf1
2 asdfasdf2
> nchar(as.character(x$ID))
[1] 4 8
>
Assuming ID is a factor, if not, you can remove the as.character().
On 9/5/07, João Fadista <[EMAIL PROTECTED]> wrote:
>
> Dear all,
>
> I would l
one: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of João Fadista
Sent: Wednesday, 5 September 2007 11:51 PM
To: r-help@stat.math.ethz.ch
Subject: [R] length of a str
Dear all,
I would like to know how can I compute the length of a string in a dataframe.
Example:
SEQUENCE ID
TGCTCCCATCTCCACGGHR04FS00645
ACTGAACTCCCATCTCCAAT HR0595847847
I would like to know how to compute the length of each SEQUENCE.