On Mon, 5 Jul 2010, Kunzler, Andreas 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 o
On Jul 5, 2010, at 9:04 AM, Kunzler, Andreas 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 n
Try this:
sapply(strsplit(as.character(Var$Var), "\\|"), length)
On Mon, Jul 5, 2010 at 11:04 AM, Kunzler, Andreas 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
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 any
4 matches
Mail list logo