[R] How to take ID of number > 7.

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Sun Apr 22 19:49:52 CEST 2012


Please provide self-contained, reproducible examples.

On Sun, 22 Apr 2012, Yellow wrote:

> O_o This is kinda interesting....
> I have 267 log2 values >= 7.
> And 295 ID numbers.....
>
> I don't see any problems in my code also:
>
> ID_Log2_Above_7 = DataFile[DataFile$log2 >= 7, c("ID", "Log2"]

Missing a parenthesis, and see below.

> # Take ID out.
>
> ID_Above_7 = ID_Log2_Above_7$ID
>
> # Only numbers, no na or inf.
>
> ID_Above_7_NO_NA = ID_Above_7[is.na(ID_Above_7)]
> ID_Above_7_FINAL = ID_Above_7_NO_NA[is.finite(ID_Above_7_NO_NA)]
>
> ############
>
> I also did the same thing for these log2, and those are 267, as it should
> be.
> But why do I have 295 ID numbers?
>
> I seriously don't get it?

You stopped working with data frames midway through, and now there is no 
well-defined correspondence between ID numbers and log2 numbers (whatever 
they are).  The troublesome values you eliminate in one column must also 
eliminate values in the other column.

Modify the line above to select rows in the data frame that are not null 
and are not finite, and you will end up with a single dataframe of data 
that meets your quality criteria.

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



More information about the R-help mailing list