[R] Adding a prefix to all values in a col in a data.frame

Henrique Dallazuanna wwwhsd at gmail.com
Mon Apr 5 19:41:48 CEST 2010


Try this:

DF <- transform(DF, V1 = sprintf('number%d', V1))


On Mon, Apr 5, 2010 at 2:38 PM, Abhishek Pratap <abhishek.vit at gmail.com> wrote:
> Hi All
>
> I am looking for a way to prefix a constant value to all the rows in column
> in a data frame.
>
> Eg.
>
> V1
> 2
> 3
> 4
> 5
>
> I want to make it like this
>
> V1
> number2
> number3
> number4
> number5
>
> Thanks!
> -Abhi
>
>        [[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.
>



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



More information about the R-help mailing list