Re: [R] Merging two columns of a data frame

2011-04-28 Thread Scott Chamberlain
what about something like: dat <- data.frame(var1 = c("a","b"), var2 = c("c","d")) dat$var3 <- sapply(dat, function(x) paste(dat$var1,dat$var2,sep=""))[,1] Scott On Thursday, April 28, 2011 at 10:22 AM, Abraham Mathew wrote: I've kind of solved the issue. > > dat$Time <- paste(dat[,2], dat[,1]

Re: [R] Merging two columns of a data frame

2011-04-28 Thread Abraham Mathew
I've kind of solved the issue. dat$Time <- paste(dat[,2], dat[,1], sep=" ") head(dat) dat[,c(1,2)] <- NA head(dat) > head(dat) Year Month Number Time 1 NA NA 0 Jan 2002 2 NA NA 0 Feb 2002 3 NA NA 0 March 2002 4 NA NA 1 April 2002 5 NA NA 0 May 2002 6 NA NA 0 June 2002 unfortunately, can I delete

[R] Merging two columns of a data frame

2011-04-28 Thread Abraham Mathew
Hi folks, I have a simple question that I just can't solve. I'm trying to merge two columns in my data frame. > sessionInfo() R version 2.13.0 (2011-04-13) Platform: i686-pc-linux-gnu (32-bit) > head(dat) Year Month Number 2002 Jan 0 2002 Feb 0 2002 March0 2002 April