try this:

> x <- read.table(textConnection("SP   variable     value
+ 425  CoolidgeLoad 6.044483e+07
+ 425  CoolidgeLoad 5.314102e+07
+ 425  CoolidgeLoad 5.287761e+07
+ 425  CoolidgeLoad 4.592003e+07
+ 425  CoolidgeLoad 4.314002e+07
+ 425  CoolidgeLoad           NA
+ 425  CoolidgeLoad           NA
+ 426  CoolidgeLoad 5.412465e+07
+ 426  CoolidgeLoad 6.122925e+07
+ 426  CoolidgeLoad 6.514926e+07
+ 426  CoolidgeLoad 6.605055e+07
+ 426  CoolidgeLoad 6.525006e+07
+ 426  CoolidgeLoad 6.166645e+07
+ 426  CoolidgeLoad 6.167510e+07
+ 427  CoolidgeLoad 5.372381e+07
+ 427  CoolidgeLoad 4.551596e+07
+ 427  CoolidgeLoad 4.246508e+07
+ 427  CoolidgeLoad           NA
+ 427  CoolidgeLoad           NA
+ 427  CoolidgeLoad           NA
+ 427  CoolidgeLoad           NA
+ 359        JMLoad 3.036887e+05
+ 359        JMLoad           NA
+ 359        JMLoad           NA
+ 359        JMLoad           NA
+ 359        JMLoad           NA
+ 359        JMLoad 3.313669e+05
+ 359        JMLoad 3.037101e+05
+ 360        JMLoad 3.036887e+05
+ 360        JMLoad 2.761196e+05
+ 360        JMLoad           NA
+ 360        JMLoad 3.037101e+05
+ 360        JMLoad 3.036887e+05
+ 360        JMLoad 3.036672e+05
+ 360        JMLoad 3.036458e+05
+ 361        JMLoad 3.036029e+05
+ 361        JMLoad 3.035814e+05
+ 361        JMLoad 3.312733e+05
+ 361        JMLoad 3.037101e+05
+ 361        JMLoad 3.313435e+05
+ 361        JMLoad 3.037315e+05
+ 361        JMLoad 3.313669e+05"), header=TRUE)
> closeAllConnections()
> x.new <- do.call(rbind, lapply(split(x, list(x$variable, x$SP)),
function(.var){
+     if (any(is.na(.var$value))) return(NULL)
+     else return(.var)
+ }))
>
> x.new
                     SP     variable      value
JMLoad.361.36       361       JMLoad   303602.9
JMLoad.361.37       361       JMLoad   303581.4
JMLoad.361.38       361       JMLoad   331273.3
JMLoad.361.39       361       JMLoad   303710.1
JMLoad.361.40       361       JMLoad   331343.5
JMLoad.361.41       361       JMLoad   303731.5
JMLoad.361.42       361       JMLoad   331366.9
CoolidgeLoad.426.8  426 CoolidgeLoad 54124650.0
CoolidgeLoad.426.9  426 CoolidgeLoad 61229250.0
CoolidgeLoad.426.10 426 CoolidgeLoad 65149260.0
CoolidgeLoad.426.11 426 CoolidgeLoad 66050550.0
CoolidgeLoad.426.12 426 CoolidgeLoad 65250060.0
CoolidgeLoad.426.13 426 CoolidgeLoad 61666450.0
CoolidgeLoad.426.14 426 CoolidgeLoad 61675100.0
>


On Wed, May 5, 2010 at 6:02 PM, emorway <emorway@engr.colostate.edu> wrote:

>
> forum,
>
> After melting a data.frame I get some 18,000+ rows (some rows below).  I
> want to filter/remove all rows that have an "SP" & "variable" value in
> common with a row containing "NA" in the value column.  So in the example
> rows below, all rows with SP=425 & variable=CoolidgeLoad would be removed
> because NA was encountered in at least one of the rows (in this case 2 of
> the rows).   Continuing the example, rows with SP=426 &
> variable="CoolidgeLoad" would be retained since "NA" doesn't appear in the
> value column of any row containing both of these values.  Rows with SP=361
> &
> variable="JMLoad" would also survive.  After performing the filter I plan
> to
> "cast" the data.
>
> -Eric
>
> SP   variable     value
> 425  CoolidgeLoad 6.044483e+07
> 425  CoolidgeLoad 5.314102e+07
> 425  CoolidgeLoad 5.287761e+07
> 425  CoolidgeLoad 4.592003e+07
> 425  CoolidgeLoad 4.314002e+07
> 425  CoolidgeLoad           NA
> 425  CoolidgeLoad           NA
> 426  CoolidgeLoad 5.412465e+07
> 426  CoolidgeLoad 6.122925e+07
> 426  CoolidgeLoad 6.514926e+07
> 426  CoolidgeLoad 6.605055e+07
> 426  CoolidgeLoad 6.525006e+07
> 426  CoolidgeLoad 6.166645e+07
> 426  CoolidgeLoad 6.167510e+07
> 427  CoolidgeLoad 5.372381e+07
> 427  CoolidgeLoad 4.551596e+07
> 427  CoolidgeLoad 4.246508e+07
> 427  CoolidgeLoad           NA
> 427  CoolidgeLoad           NA
> 427  CoolidgeLoad           NA
> 427  CoolidgeLoad           NA
> 359        JMLoad 3.036887e+05
> 359        JMLoad           NA
> 359        JMLoad           NA
> 359        JMLoad           NA
> 359        JMLoad           NA
> 359        JMLoad 3.313669e+05
> 359        JMLoad 3.037101e+05
> 360        JMLoad 3.036887e+05
> 360        JMLoad 2.761196e+05
> 360        JMLoad           NA
> 360        JMLoad 3.037101e+05
> 360        JMLoad 3.036887e+05
> 360        JMLoad 3.036672e+05
> 360        JMLoad 3.036458e+05
> 361        JMLoad 3.036029e+05
> 361        JMLoad 3.035814e+05
> 361        JMLoad 3.312733e+05
> 361        JMLoad 3.037101e+05
> 361        JMLoad 3.313435e+05
> 361        JMLoad 3.037315e+05
> 361        JMLoad 3.313669e+05
> --
> View this message in context:
> http://r.789695.n4.nabble.com/melt-remove-rows-with-common-id-if-NA-encountered-in-value-tp2131770p2131770.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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<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?

	[[alternative HTML version deleted]]

