Hi there,
I have a data frame with a column named "Flags", whose contents are
strings
containing any of the following characters, multiple characters allowed:
A,B,C,D,E,F,G.
Here is the head:
GeocodeID PlaceID CountyCode CBSACode StateProvCode PropertyTypeGroupID
Flags
1 0 0 0 0
AK 1 ABC
2 0 0 0 0
AK 2 AC
3 0 0 0 0
AK 3 BC
4 0 0 0 0
AK 4 CD
5 0 0 0 0
AK 14 CD
6 0 0 0 0
AK 15 ACDE
7 0 0 0 0
AL 1
I want to select only the rows whose "Flag" element contains the
character
G. Is there a simple way to do this, or should I perhaps come up with a
different system of flags, which is totally up to me?
Thanks,
Alex
[[alternative HTML version deleted]]
Dear all, If you have experience with the -network- package, can you show me how to remove nodes based on their degrees? For instance, removing all nodes with an out-degree or in-degree of 1? Thank you very much for your help! Rick
Tena koe Alexis
?regexpr
yourDataFrame[regexpr('G', yourDataFrame$Flags)>0,]
HTH ...
Peter Alspach
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Alexis Champsaur
> Sent: Wednesday, 28 April 2010 11:49 a.m.
> To: r-help at stat.math.ethz.ch
> Subject: [R] Selecting rows based on contents of string
>
> Hi there,
> I have a data frame with a column named "Flags", whose contents
are
> strings
> containing any of the following characters, multiple characters
> allowed:
> A,B,C,D,E,F,G.
>
> Here is the head:
> GeocodeID PlaceID CountyCode CBSACode StateProvCode
> PropertyTypeGroupID
> Flags
> 1 0 0 0 0
> AK 1 ABC
> 2 0 0 0 0
> AK 2 AC
> 3 0 0 0 0
> AK 3 BC
> 4 0 0 0 0
> AK 4 CD
> 5 0 0 0 0
> AK 14 CD
> 6 0 0 0 0
> AK 15 ACDE
> 7 0 0 0 0
> AL 1
>
> I want to select only the rows whose "Flag" element contains the
> character
> G. Is there a simple way to do this, or should I perhaps come up with
a> different system of flags, which is totally up to me?
>
> Thanks,
>
> Alex
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
Hi,
There's probably an easier or more readable way to do it, but:
df <- data.frame(cbind(letters, var= runif(26, 2, 3)))
df[df$letters[grep("[G]", df$letters, ignore.case=TRUE)],]
Cheers!!
Albert-Jan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public
order, irrigation, roads, a fresh water system, and public health, what have the
Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- On Wed, 4/28/10, Alexis Champsaur <alexis.champsaur@gmail.com> wrote:
From: Alexis Champsaur <alexis.champsaur@gmail.com>
Subject: [R] Selecting rows based on contents of string
To: r-help@stat.math.ethz.ch
Date: Wednesday, April 28, 2010, 1:49 AM
Hi there,
I have a data frame with a column named "Flags", whose contents are
strings
containing any of the following characters, multiple characters allowed:
A,B,C,D,E,F,G.
Here is the head:
GeocodeID PlaceID CountyCode CBSACode StateProvCode PropertyTypeGroupID
Flags
1 0 0 0 0
AK 1 ABC
2 0 0 0 0
AK 2 AC
3 0 0 0 0
AK 3 BC
4 0 0 0 0
AK 4 CD
5 0 0 0 0
AK 14 CD
6 0 0 0 0
AK 15 ACDE
7 0 0 0 0
AL 1
I want to select only the rows whose "Flag" element contains the
character
G. Is there a simple way to do this, or should I perhaps come up with a
different system of flags, which is totally up to me?
Thanks,
Alex
[[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.
[[alternative HTML version deleted]]
Dear all, If you have experience with the -network- package, can you show me how to remove nodes based on their degrees? For instance, removing all nodes with an out-degree or in-degree of 1? Thank you very much for your help! Rick