[R] R help

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Tue Oct 13 22:24:47 CEST 2015


In general you should read the Posting Guide mentioned at the bottom of every email, which points out that you should post in plain text. Figuring out how to send plain text email in your email client will help you make sure that we see what you see. 

You should also try to insert reproducible code in your email rather than isolated snippets. Read the discussion at [1] to learn more.

filter(df, grepl( "\\.002", as.character( Number ) ) )

If you import the data with the stringsAsFactors=TRUE option you could get rid of the as.character conversion.  You should also look at the help for %in% because it compares the whole string, not sub strings.

?"%in%"

[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On October 13, 2015 11:24:34 AM PDT, Clayton Samples <claytonsamples at gmail.com> wrote:
>Hello R community,
>
>I need a bit of direction. I am new to R, so please forgive any
>mistakes or
>confusion.
>
>
>Here is an example of the columns and data contained in my data frame.
>Number: Factor w 345196 levels "1.001", "1.002", "1.003", "2.001",
>"2.002",
>"2.003"
>Name: factor w 2 levels ("X", "Y")
>Variable: factor w 21 levels "unknown", "known"
>Amount: num(1, 2, 3, 4, 5, 6)
>
>My objective is to filter based on numbers ending in .002 within column
>Number
>
>I have used the melt function to organize the data and then tried
>
>filter(df, PO.Number %in% c(.002))
>
>However, this didn't work.
>
>Thanks for the help.
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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