Try this:

sapply(strsplit(as.character(Var$Var), "\\|"), length)

On Mon, Jul 5, 2010 at 11:04 AM, Kunzler, Andreas <a.kunz...@bzaek.de>wrote:

> Dear list,
>
> I'm looking for a way to count the number of "|" within an object.
> The character "|" is used to separated ids.
>
> Assume a data (d) structure like
>
> Var
> NA
> NA
> NA
> NA
> NA
> 1
> 1|2
> 1|22|45
> 3
> 4b|24789
>
> I need to know the maximum number of ids within one object. In this case 3
> (1|22|45)
>
>
> Does anybody know a better way?
>
> Thanks
>
> Mit freundlichen Grüßen
>
> Andreas Kunzler
> ____________________________
> Bundeszahnärztekammer (BZÄK)
> Chausseestraße 13
> 10115 Berlin
>
> Tel.: 030 40005-113
> Fax:  030 40005-119
>
> E-Mail: a.kunz...@bzaek.de
>
> ______________________________________________
> R-help@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

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to