Re: [R] Extracting dates to create a new variable

2016-08-10 Thread Adams, Jean
Try this. dfsub <- df[df$deps %in% c("CC", "DD", "FF"), ] names(dfsub) <- c("Subject", "newdate", "origdep") final <- merge(df, dfsub) Jean On Wed, Aug 10, 2016 at 10:58 AM, Farnoosh Sheikhi via R-help < r-help@r-project.org> wrote: > blockquote, div.yahoo_quoted { margin-left: 0 !important; b

[R] Extracting dates to create a new variable

2016-08-10 Thread Farnoosh Sheikhi via R-help
blockquote, div.yahoo_quoted { margin-left: 0 !important; border-left:1px #715FFA solid !important; padding-left:1ex !important; background-color:white !important; } Hi  I have a data set like below and wanted to create a new date variable by extracting the dates for specific departments.I wa

Re: [R] Extracting dates to create a new variable

2016-08-08 Thread Ulrik Stervbo
Getting the dates of the departments CC, DD, FF can be done with subset(df, deps %in% c("CC", "DD", "FF")) I am not sure how you intend to match these identified dates with other departments? From your example you sometimes replace earlier dates, sometimes later dates. HTH Ulrik On Mon, 8 Aug 2

[R] Extracting dates to create a new variable

2016-08-08 Thread Farnoosh Sheikhi via R-help
Hi there,  I have a data set like below and wanted to create a new date variable by extracting the dates for specific departments.I want to extract the dates for departments CC, DD, FF,  put it in a new column and repeat it for other unique IDs. Subject<- c("2", "2", "2", "3", "3", "3", "4", "4"