Amazing.
 Thanks a lot

milton

On Mon, Oct 19, 2009 at 12:55 PM, Henrique Dallazuanna <www...@gmail.com>wrote:

> Milton,
>
> Try this:
>
> myDF[grep("k", names(myDF))] <- sapply(myDF[grep("k", names(myDF))],
> function(idx)myDF$namesp[idx])
>
>
> On Mon, Oct 19, 2009 at 2:03 PM, milton ruser <milton.ru...@gmail.com>
> wrote:
> > Dear R-gurus,
> >
> > Just supose I have a dara.frame that looks like
> >
> > myDF<-read.table(stdin(),head=T,sep=",")
> > codID,namesp,k1,k2,k3,k4
> > 1,spA,2,5,6,3
> > 2,spB,4,5,4,6
> > 3,spC,2,1,5,6
> > 4,spC,5,4,3,2
> > 5,spD,1,2,3,4
> > 6,spE,2,4,3,1
> >
> > I need to update the columns k1-k4 with the namesp, but
> > considering the math between Kx and codID.
> >
> > My desired output must looks like:
> >
> > codID,namesp,k1,k2,k3,k4
> > 1,spA,spB,spD,spE,spC
> > 2,spB,...
> > 3,spC,...
> > 4,spC,...
> > 5,spD,...
> > 6,spE,...
> >
> > Any help are welcome.
> >
> > cheers
> >
> > milton
> >
> >        [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > 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<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]]

______________________________________________
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.

Reply via email to