[R] Basic question ( too broad for help topics).
Jim Burke
j.burke at earthlink.net
Thu Oct 29 08:14:44 CET 2009
Thanks Ista,
Your suggestion worked like a charm.
Mark, thanks to you too. But don't worry about the data I sent to you.
Good night everyone,
Jim
Ista Zahn wrote:
> Hi Jim,
>
> out_df <- my_df[ my_df$STREP %in% my_num, c("COUNTY", "FIPS", "STSEN",
> "STREP", "PREC")]
>
> should do the trick. See
>
> ?match
>
> for details.
>
> On Thu, Oct 29, 2009 at 1:53 AM, Jim Burke <j.burke at earthlink.net> wrote:
>
>> I have searched help topics but don't know exactly what to search for.
>> Need to use my_num to find any matching STREPs in my_df
>>
>> 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"
>> out_df <- my_df[ my_df$STREP=="101", c("COUNTY", "FIPS", "STSEN", "STREP",
>> "PREC")]
>>
>> ## A comparative SQL command
>> ## SELECT
>> ## COUNTY, FIPS, STSEN, STREP, PREC
>> ## FROM my_df
>> ## WHERE my_df.STREP
>> IN("101","102","103","104","105","107","108","112","113","114","115")
>> ## ORDER BY STREP;
>>
>> Thanks for any help,
>> Jim
>>
>> ______________________________________________
>> 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.
>>
>>
>
>
>
>
More information about the R-help
mailing list