[R] Creating a vector with repeating dates
Dear R forum I have a data.frame df = data.frame(dates = c(4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013), values = c(47, 38, 56, 92)) I need to to create a vector by repeating the dates as Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013 i.e. I need to create a new vector as given below which I need to use for some other purpose. Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Is it possible to construct such a column? Regards Katherine [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Creating a vector with repeating dates
?rep On Wed, Apr 17, 2013 at 11:11 AM, Katherine Gobin katherine_go...@yahoo.com wrote: Dear R forum I have a data.frame df = data.frame(dates = c(4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013), values = c(47, 38, 56, 92)) I need to to create a vector by repeating the dates as Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013 i.e. I need to create a new vector as given below which I need to use for some other purpose. Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Is it possible to construct such a column? Regards Katherine [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Creating a vector with repeating dates
Dear Andrija Djurovic, Thanks for the suggestion. Ia m aware of rep. However, here I need to repeat not only dates, but a string Current_date. Thus, I need to create a vector ( to be included in some other data.frame) with the name say dt which will contain dt Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 So this is combination of dates and a string. Hence, I am just wondering if it is possible to create such a vector or not? Regards Katherine --- On Wed, 17/4/13, andrija djurovic djandr...@gmail.com wrote: From: andrija djurovic djandr...@gmail.com Subject: Re: [R] Creating a vector with repeating dates To: Katherine Gobin katherine_go...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Date: Wednesday, 17 April, 2013, 10:14 AM ?rep On Wed, Apr 17, 2013 at 11:11 AM, Katherine Gobin katherine_go...@yahoo.com wrote: Dear R forum I have a data.frame df = data.frame(dates = c(4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013), values = c(47, 38, 56, 92)) I need to to create a vector by repeating the dates as Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013 i.e. I need to create a new vector as given below which I need to use for some other purpose. Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Is it possible to construct such a column? Regards Katherine [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Creating a vector with repeating dates
Hello, Try the following. rep(c(Current_date, as.character(df$dates)), 3) Hope this helps, Rui Barradas Em 17-04-2013 10:11, Katherine Gobin escreveu: Dear R forum I have a data.frame df = data.frame(dates = c(4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013), values = c(47, 38, 56, 92)) I need to to create a vector by repeating the dates as Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013 i.e. I need to create a new vector as given below which I need to use for some other purpose. Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Is it possible to construct such a column? Regards Katherine [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] Creating a vector with repeating dates
Hi. Here are some examples that can maybe help you: a - Current date b - Sys.Date()-1:5 a b class(a) class(b) c(a,b) mode(b) as.numeric(b) class(c(a,b)) c(a, as.character(b)) class(c(a,b)) class(c(a,as.character(b))) Hope this helps. On Wed, Apr 17, 2013 at 11:21 AM, Katherine Gobin katherine_go...@yahoo.com wrote: Dear Andrija Djurovic, Thanks for the suggestion. Ia m aware of rep. However, here I need to repeat not only dates, but a string Current_date. Thus, I need to create a vector ( to be included in some other data.frame) with the name say dt which will contain dt Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 So this is combination of dates and a string. Hence, I am just wondering if it is possible to create such a vector or not? Regards Katherine --- On *Wed, 17/4/13, andrija djurovic djandr...@gmail.com* wrote: From: andrija djurovic djandr...@gmail.com Subject: Re: [R] Creating a vector with repeating dates To: Katherine Gobin katherine_go...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Date: Wednesday, 17 April, 2013, 10:14 AM ?rep On Wed, Apr 17, 2013 at 11:11 AM, Katherine Gobin katherine_go...@yahoo.com http://mc/compose?to=katherine_go...@yahoo.com wrote: Dear R forum I have a data.frame df = data.frame(dates = c(4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013), values = c(47, 38, 56, 92)) I need to to create a vector by repeating the dates as Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013 i.e. I need to create a new vector as given below which I need to use for some other purpose. Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Is it possible to construct such a column? Regards Katherine [[alternative HTML version deleted]] __ R-help@r-project.org http://mc/compose?to=R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Creating a vector with repeating dates
On 04/17/2013 07:11 PM, Katherine Gobin wrote: Dear R forum I have a data.frame df = data.frame(dates = c(4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013), values = c(47, 38, 56, 92)) I need to to create a vector by repeating the dates as Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013 i.e. I need to create a new vector as given below which I need to use for some other purpose. Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Is it possible to construct such a column? Hi Katherine, How about: rep(c(Current date,paste(4,15:12,2013,sep=/)),3) Jim __ R-help@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.
Re: [R] Creating a vector with repeating dates
Dear Sir, Thanks a lot for your valuable suggestions and help. Regards Katherine --- On Wed, 17/4/13, Jim Lemon j...@bitwrit.com.au wrote: From: Jim Lemon j...@bitwrit.com.au Subject: Re: [R] Creating a vector with repeating dates To: Katherine Gobin katherine_go...@yahoo.com Cc: r-help@r-project.org Date: Wednesday, 17 April, 2013, 10:35 AM On 04/17/2013 07:11 PM, Katherine Gobin wrote: Dear R forum I have a data.frame df = data.frame(dates = c(4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013), values = c(47, 38, 56, 92)) I need to to create a vector by repeating the dates as Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013, Current_date, 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013 i.e. I need to create a new vector as given below which I need to use for some other purpose. Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Current_date 4/15/2013 4/14/2013 4/13/2013 4/12/2013 Is it possible to construct such a column? Hi Katherine, How about: rep(c(Current date,paste(4,15:12,2013,sep=/)),3) Jim [[alternative HTML version deleted]] __ R-help@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.