HI,

Perhaps:

cbind(ID=DF$ID,as.data.frame(sapply(levels(VAL$type),
function(x){DF[,x]=VAL$number[VAL$type==x];DF[,x]})))


On 25/10/2007, Lauri Nikkinen <lauri.nikkinen@iki.fi> wrote:
>
> Hi folks,
>
> I have two dataframes like these:
>
> DF <- data.frame(ID=c("AA1234","AB3233","AC4353","AD2345","AE7453"),
> CK32344=c(1,3,2,4,1), CK32664=c(2,1,1,2,3), CK33422=c(2,2,1,3,2))
> VAL <- data.frame(num=rep(6,3), type=c("CK32344", "CK32664",
> "CK33422"), number=c("32","452","234"))
>
> I want to replace the values in DF$CK32344, DF$CK32664 DF$CK33422 with
> the corresponding number in the VAL$number.
>
> The results should look like this:
>
> RES <- data.frame(ID=c("AA1234","AB3233","AC4353","AD2345","AE7453"),
> CK32344=rep(32, 5), CK32664=rep(425, 5), CK33422=rep(234, 5))
>
> How do I do that?
>
> Regards,
> Lauri
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

