[R] R Help

PIKAL Petr petr.pikal at precheza.cz
Fri Jul 19 13:48:55 CEST 2013


Hi

It would be better if you provided either str(yourdata) or dput(yourdata) 

(or a part illustrating those 2 kinds of missing values)

Anyway I would use NA for missing and some other identifier for empty.

temp
   a      b  c
1  1  empty   
2 NA filled xx
3  2 filled xx

is.na(temp)
         a     b     c
[1,] FALSE FALSE FALSE
[2,]  TRUE FALSE FALSE
[3,] FALSE FALSE FALSE

dput(temp)
structure(list(a = c(1L, NA, 2L), b = structure(c(1L, 2L, 2L), .Label = c("empty", 
"filled"), class = "factor"), c = structure(c(1L, 2L, 2L), .Label = c("", 
"xx"), class = "factor")), .Names = c("a", "b", "c"), class = "data.frame", row.names = c(NA, 
-3L))

str(temp)
'data.frame':   3 obs. of  3 variables:
 $ a: int  1 NA 2
 $ b: Factor w/ 2 levels "empty","filled": 1 2 2
 $ c: Factor w/ 2 levels "","xx": 1 2 2

The only real NA value which can be used for imputation is in first column.

Regards
Petr

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Ma Teresa Martinez Soriano
> Sent: Friday, July 19, 2013 11:28 AM
> To: r-help at R-project.org
> Subject: [R] R Help
> 
> Hi
> everyone,
> 
> I have
> a dataset which I am handling  with
> R . Unfortunately I have two kinds of empty cells, one corresponds to
> missing values and the other one is empty because it has to.
> 
> I 'm going
> to put an example (just a part of my dataset ) to try to clarify my
> question:
> 
> missing
> values are represented withNAs
> 
> 
> Enterprise
> Data of Stablishment   Earnings
> 2005          earning
> 2006         earnings 2007 earning 2008
> 
> Enterprise
> 1
> 05/06/2007
> It has to be empty      It has to be
> empty
> 2,3
> NA
> 
> Enterprise
> 2
> 09/08/2005
> 2.3
> 3,6
> NA
> 1.6
> 
> 
> 
> My intention is to find this missing values using imputation (library
> VIM) . How could I differenciate this NA with Cells that have to be
> empty?? I have tried putting Na for missing values and Nan for the
> others but it doesn't work because R imputes everythitng.
> Could you answer me
> to this e-mail
> 
> Thanks in
> advance
> 
> 
> 	[[alternative HTML version deleted]]



More information about the R-help mailing list