Responsive Ad Area

Share This Post

test

Merge Two Columns As Date

I am trying to merge two different columns in R, and need to convert them into date with format yyyymm as well, which looks like this:
yyyy mm
1991 1
1991 2
1991 3
1992 1
1992 2
1992 3

I have tried this code:

df$date <- as.Date(with(df, paste(yyyy, mm, sep="-")), "%Y-%m")

But the result resulting to NA:
yyyy mm date
1991 1 NA
1991 2 NA
1991 3 NA
1992 1 NA
1992 2 NA
1992 3 NA

Can anybody suggest or point out which part of the code is incorrect?


Merge Two Columns As Date
Merge Two Columns As Date
test
{$excerpt:n}

Share This Post

Leave a Reply

Your email address will not be Publishedd. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Skip to toolbar