Shant Ch
2011-Jul-07 20:40 UTC
[R] subset from a dataset after comparing its one column to a related vector
Hello R users,
I have two data sets like the following. Form of dataset:
data:
X1 X2 X3 X4 X5
1902 RE 3 594 9
1903 RE 3 1340 7
1904 AA 3 760 14
1908 RE 4 1759 18
1909 EX 2 387 1
2901 AU 6 3116 2
3801 AA 1 304 29
3902 RE 5 2482 6
I need to select rows of a data set based on the common observations of X1.
Using intersect command I got the common observations of X1 from the two data
sets as:
common=c(1902, 1904, 1908, 1909, 3801).
Using subset command I can select portions separately. But in general if I am
given this type of dataset - "data" with large number of rows and also
a list of
X1 - "common" containing many elements, can anyone please let me know
how to
select portion of the data whose X1 values are same as common values.
If any questions let me know.
Shant.
[[alternative HTML version deleted]]
David Winsemius
2011-Jul-07 20:58 UTC
[R] subset from a dataset after comparing its one column to a related vector
On Jul 7, 2011, at 4:40 PM, Shant Ch wrote:> Hello R users, > > I have two data sets like the following. Form of dataset: > > data: > > X1 X2 X3 X4 X5 > 1902 RE 3 594 9 > 1903 RE 3 1340 7 > 1904 AA 3 760 14 > 1908 RE 4 1759 18 > 1909 EX 2 387 1 > 2901 AU 6 3116 2 > 3801 AA 1 304 29 > 3902 RE 5 2482 6 > > I need to select rows of a data set based on the common observations > of X1. > Using intersect command I got the common observations of X1 from the > two data > sets as: > > common=c(1902, 1904, 1908, 1909, 3801). > > Using subset command I can select portions separately. But in > general if I am > given this type of dataset - "data" with large number of rows and > also a list of > X1 - "common" containing many elements, can anyone please let me > know how to > select portion of the data whose X1 values are same as common values.subset(dfrm, x1 %in% common) ?subset> > If any questions let me know. > > Shant. > [[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.David Winsemius, MD West Hartford, CT
Shant Ch
2011-Jul-10 22:43 UTC
[R] R code to extract shape polygons for any state for loading into Geobugs
Hello R users,
I am fitting a spatio-temporal model for the areal data related to school
districts of Texas, US using geobugs. For that I need to load the polygon shape
file in geobugs.In Bradley Carlin's website there was an S-plus program
called
poly.S to extract polygons for any state in the United States in the
appropriate format for loading into GeoBUGS which is no more now and that too
on S. Is there any R code to extract the polygons for all school districts of a
state in the United States or something of that type, the format which can be
used in geobugs?
Bhargab
________________________________
To: r-help@r-project.org
Sent: Thu, July 7, 2011 4:40:19 PM
Subject: [R] subset from a dataset after comparing its one column to a related
vector
Hello R users,
I have two data sets like the following. Form of dataset:
data:
X1 X2 X3 X4 X5
1902 RE 3 594 9
1903 RE 3 1340 7
1904 AA 3 760 14
1908 RE 4 1759 18
1909 EX 2 387 1
2901 AU 6 3116 2
3801 AA 1 304 29
3902 RE 5 2482 6
I need to select rows of a data set based on the common observations of X1.
Using intersect command I got the common observations of X1 from the two data
sets as:
common=c(1902, 1904, 1908, 1909, 3801).
Using subset command I can select portions separately. But in general if I am
given this type of dataset - "data" with large number of rows and also
a list of
X1 - "common" containing many elements, can anyone please let me know
how to
select portion of the data whose X1 values are same as common values.
If any questions let me know.
Shant.
[[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]]