[R] concatenating a string to a column
Peter Langfelder
peter.langfelder at gmail.com
Wed Nov 10 06:15:36 CET 2010
On Tue, Nov 9, 2010 at 9:09 PM, <sachinthaka.abeywardana at allianz.com.au> wrote:
>
> Hi All,
>
> Suppose I want to concatenate a zero to all the values to a column called
> period in data frame A. I want to do the following but the following
> command actually deletes the entire column altogether.
>
> A$period<-cat(A$period,"0",sep="");
cat returns NULL, so you get NULL in A$period.
try
A$period<-paste(A$period,"0",sep="");
Of course, if A$period are integer numbers, a simple way of adding a
zero is to multiply everything by 10.
Peter
More information about the R-help
mailing list