Re: [R] NAs introduced by coercion

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Tue, 11 Mar 2008 13:08:41 +0000 (UTC)

Wim Bertels <wim.bertels_at_khleuven.be> wrote in news:1205233503.5326.26.camel_at_localhost:

> Hallo,
>
> i get a warning message that NAs are introduced by coercion,
> so my idea is to write a function to see which values are turned
> into NA
>
> For this i need to write a function to go through (loop) the
> original data and the transformed (with the introduced na) to see
> which data were transformed to NA.
> So the return of this function should be a 2*many matrix like
> structure, eg
> names: indexolddata, valueolddata
> 45, 789
> 89, 4568
> and so on
> (on the data that were transformed into an NA)
>
> I am doing something wrong.

Try to build on this:

x <- data.frame(var1=1:10,var2=11:20)
x[5,2]<-NA
x[7,2]<-NA
row(x)[is.na(x)]

returns [1] 5 7

If you wanted the whole row, you would use that vector as a row index:

 x[row(x)[is.na(x)],]

returns:
  var1 var2
5 5 NA
7 7 NA

-- 
David Winsemius

______________________________________________
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.
Received on Tue 11 Mar 2008 - 13:11:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 11 Mar 2008 - 13:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive