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

From: Abraham Mathew <abmathewks_at_gmail.com>
Date: Thu, 28 Apr 2011 11:22:25 -0400

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 the Year and Month Columns. Once that's done, I can reconfigure the columns

Abraham

On Thu, Apr 28, 2011 at 11:00 AM, Abraham Mathew <abmathewks_at_gmail.com>wrote:

>
> 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 March 0
> 2002 April 1
> 2002 May 0
> 2002 June 0
>
> I tried to do the following, but it doesn't work.
>
> dat$Time <- merge(dat[,1], dat[,2])
> head(dat)
>
>
> Help, Abraham.
>
>
>
>
>

        [[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. Received on Thu 28 Apr 2011 - 16:49:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Apr 2011 - 04:00:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive