[R] inserting values for null

Moshe Olshansky m_olshansky at yahoo.com
Thu Sep 18 06:16:51 CEST 2008


Hi Ramya,

Assuming that the problem is well defined (i.e. the values in col1 of the data.frames are unique and every value in D.F.sub.2[,1] appears also in D.F1[,1]) you can do the following:

ind <- match(D.F.sub.2[,1],D.F1[,1])
D.F1[ind,] <- D.F.sub.2


--- On Thu, 18/9/08, Rajasekaramya <ramya.victory at gmail.com> wrote:

> From: Rajasekaramya <ramya.victory at gmail.com>
> Subject: [R]  inserting values for null
> To: r-help at r-project.org
> Received: Thursday, 18 September, 2008, 2:13 AM
> I have a dataframe D.F1 
> 
> >dim (D.F1) 
> 14351 9 
> This dataframe has values and for some 1000 rows it holds
> NULL values.I hace
> found the missing values for about 500 and have those in
> another dataframe
> D.F.sub.2 
> 
> >dim(D.F.sub.2) 
> 500 9 
> as dataframe is a subset of D.F1 the coulmn 1 in D.F.sub.2
> is a subset of
> D.F1.I have to insert the values in D.F1 in other fields
> while the coulmn 1
> in both the main table and sub table matches. 
> Ih short i have to insert a dataframe (D.F.sub.2) into the
> main D.F1 using
> the column1 that hold similar values. 
> 
> Kindly plz help me.
> 
> Ramya
> -- 
> View this message in context:
> http://www.nabble.com/inserting-values-for-null-tp19535742p19535742.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.



More information about the R-help mailing list