Re: [R] to avoid a do loop

2013-09-08 Thread Arnaud Michel
Hi This below system.time of the 3 solutions with a large dataframe df1 (nrow=55000). # Arun system.time(df1$CatEch1 <- paste0(df1$Cat,".",sprintf("%02d",df1$Ech))) # user system elapsed # 0.060.000.06 # Rui Barradas system.time(df1$CatEch2 <- pastedf1$Cat, sprintf("%02d", df1$Ech),

Re: [R] to avoid a do loop

2013-09-08 Thread Arnaud Michel
Thanks to all three for your fast answer Michel Le 08/09/2013 18:41, Renaud Lancelot a écrit : > paste(df1$Cat, > formatC(df1$Ech, flag = "0", width = max(nchar(df1$Ech))), > sep = ".") > > > > 2013/9/8 Arnaud Michel > > > Hello > I have a large

Re: [R] to avoid a do loop

2013-09-08 Thread Renaud Lancelot
paste(df1$Cat, formatC(df1$Ech, flag = "0", width = max(nchar(df1$Ech))), sep = ".") 2013/9/8 Arnaud Michel > Hello > I have a large dataframe (nrow=55000). > This below df1 an extract of the original dataframe > > dput(df1) > structure(list(Cat = c(6, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4

Re: [R] to avoid a do loop

2013-09-08 Thread Rui Barradas
Hello, Try the following. df3 <- df1 df3$CatEch <- paste(df1$Cat, sprintf("%02d", df1$Ech), sep = ".") identical(df2, df3) # TRUE Hope this helps, Rui Barradas Em 08-09-2013 17:22, Arnaud Michel escreveu: Hello I have a large dataframe (nrow=55000). This below df1 an extract of the orig

Re: [R] to avoid a do loop

2013-09-08 Thread arun
Hi, Try: df1$CatEch<-paste0(df1[,1],".",sprintf("%02d",df1[,2]))  identical(df1,df2) #[1] TRUE A.K. - Original Message - From: Arnaud Michel To: R help Cc: Sent: Sunday, September 8, 2013 12:22 PM Subject: [R] to avoid a do loop Hello I have a large dataframe  (nrow=55000). This belo