Re: [R] Missing Data and applying

From: jim holtman <jholtman_at_gmail.com>
Date: Mon, 09 Jun 2008 11:44:33 -0400

This might help the first question:

> da <- (-1):1
> x <- data.frame(a1=sample(da,10,TRUE), a2=sample(da,10,TRUE),
a3=sample(da,10,TRUE))
> x

   a1 a2 a3
1 0 1 0
2 0 0 1
3 0 1 0

4  -1  0 -1
5   1  0 -1
6   1  1 -1
7   1 -1 -1

8 -1 0 0
9 1 1 0
10 0 1 0
> is.na(x[1:3]) <- x[1:3] == -1
> x

   a1 a2 a3
1 0 1 0
2 0 0 1
3 0 1 0
4 NA 0 NA
5 1 0 NA
6 1 1 NA
7 1 NA NA
8 NA 0 0
9 1 1 0
10 0 1 0
>

On Mon, Jun 9, 2008 at 11:18 AM, Michael Pearmain <mpearmain_at_google.com> wrote:

> Hi All,
>
> Newbie question that i'm sure is easy, but i can't seem to apply properly
>
> I read in a datafram from a CSV file and i want to tell R that from coloum
> "n_0" to "n_32" the value "-1" is missing data
> i was looking at the
> is.na(xx) <- c(..,...,) idea but i can't seem to apply it properly, can
> anyone offer advice?
>
> On a side issue while i'm asking i have a an XML that i intend to use to
> add
> value labels and variable labels to the dataframe (using a python script)
> but i can't seem to find the syntax for adding value labels? i.e 1=Male
> 2=Female
>
> the labels command doesn't look like the one i want to use, and i've
> searched the archives but to no avail (maybe it's a too simple, but i have
> looked)
>
> Any help willing accepted
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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<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 you are trying to solve?

	[[alternative HTML version deleted]]

______________________________________________
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 Mon 09 Jun 2008 - 16:27:35 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 Mon 09 Jun 2008 - 16:30:39 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