[R] Basic simple question

2009-10-29 Thread Jim Burke

I have a statement like below.

my_num - 
c(101,102,103,104,105,107,108,112,113,114,115)


my_df has 8,000 different STREPS in it.

I have a statement where I can select ONE item from data frame my_df
txhd_df - prec_dist_df[ my_df$STREP==101, c(COUNTY, FIPS, 
STSEN, STREP, PREC)]


I would like to make R compare and deliver only the STREPS that are in 
my_num.


A comparative SQL command WHERE STREP 
IN(101,102,103,104,105,107,108,112,113,114,115)


Thanks for any help,
Jim

__
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.


Re: [R] Basic simple question

2009-10-29 Thread jim holtman
try:

txhd_df - prec_dist_df[ my_df$STREP %in% my_num, c(COUNTY, FIPS,
STSEN, STREP, PREC)]

On Thu, Oct 29, 2009 at 1:04 AM, Jim Burke j.bu...@earthlink.net wrote:
 I have a statement like below.

 my_num -
 c(101,102,103,104,105,107,108,112,113,114,115)

 my_df has 8,000 different STREPS in it.

 I have a statement where I can select ONE item from data frame my_df
 txhd_df - prec_dist_df[ my_df$STREP==101, c(COUNTY, FIPS, STSEN,
 STREP, PREC)]

 I would like to make R compare and deliver only the STREPS that are in
 my_num.

 A comparative SQL command WHERE STREP
 IN(101,102,103,104,105,107,108,112,113,114,115)

 Thanks for any help,
 Jim

 __
 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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
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.