Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
>>>> > >>>>> > # convert strings (or factors) to a date object >>>>> > >>>>> > a1$date <- as.Date(a1$date, “%m-%d-%y”) >>>>> > >>>>> > >>>>> > >>>>> > # No

Re: [R] Date Time in R

2016-07-26 Thread William Dunlap via R-help
> >>>> > >>>> > Please find the details: (i have changed name from eir to a1, rest >>>> all is >>>> > same) >>>> > >>>> > >>>> > >>>> > str(a1$date) >>>> > >>&

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
;>> > >>> > # extract the weekdays as number >>> > >>> > weekdays <- wday(a1$date) >>> > >>> > >>> > >>> > # note can’t have spaces in variable names >>> > >>> > week_names <- wda

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
by >> default >> > >> > # so no need for the mdy() or ymd() function >> > >> > >> > >> > # extract the weekdays as number >> > >> > weekdays <- wday(a1$date) >> > >> > >> > >> >

Re: [R] Date Time in R

2016-07-26 Thread William Dunlap via R-help
names > > > > week_names <- wday(a1$date, label=TRUE) > > > > > > > > > > > > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com] > > *Sent:* July 26, 2016 12:16 PM > > *To:* Tom Wright > > *Cc:* David L Carlson ; r-help >

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
gt; > > > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com] > *Sent:* July 26, 2016 12:16 PM > *To:* Tom Wright > *Cc:* David L Carlson ; r-help > > *Subject:* Re: [R] Date Time in R > > > > Hello Tom, > > > > Please find the details: (i have change

Re: [R] Date Time in R

2016-07-26 Thread Tom Wright
- wday(a1$date) # note can’t have spaces in variable names week_names <- wday(a1$date, label=TRUE) *From:* Shivi Bhatia [mailto:shivipm...@gmail.com] *Sent:* July 26, 2016 12:16 PM *To:* Tom Wright *Cc:* David L Carlson ; r-help *Subject:* Re: [R] Date Time in R Hello Tom, Please

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
rmation before doing any processing on the date > (i.e. before the as.Date() function) we may be able to help. > > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi > Bhatia > Sent: July 26, 2016 11:46 AM > To: David L Ca

Re: [R] Date Time in R

2016-07-26 Thread Hadley Wickham
; relevant in this context. > > On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson wrote: > >> Show us the output, don’t just tell us what you are seeing. If the dates >> are correct in the csv file, show us the structure of the data frame you >> created with read.csv() an

Re: [R] Date Time in R

2016-07-26 Thread Tom Wright
-help-boun...@r-project.org] On Behalf Of Shivi Bhatia Sent: July 26, 2016 11:46 AM To: David L Carlson Cc: r-help Subject: Re: [R] Date Time in R Hi David please see the code and some reproducible data: eir$date<- as.Date(eir$date,format = "%m-%d-%y") then i had used the lubridate li

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
n this context. > > On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson > wrote: > >> Show us the output, don’t just tell us what you are seeing. If the dates >> are correct in the csv file, show us the structure of the data frame you >> created with read.csv() and show

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
the command(s) you used to convert the > character data to date format. The solution is likely to be simple if you > will cut/paste the R console and not just describe what is happening. > > > > David C > > > > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com] >

Re: [R] Date Time in R

2016-07-26 Thread Nordlund, Dan (DSHS/RDA)
om: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi > Bhatia > Sent: Tuesday, July 26, 2016 4:43 AM > To: Duncan Murdoch > Cc: r-help@r-project.org > Subject: Re: [R] Date Time in R > > Thanks Duncan for the quick response. I will check again as you suggested

Re: [R] Date Time in R

2016-07-26 Thread David L Carlson
will cut/paste the R console and not just describe what is happening. David C From: Shivi Bhatia [mailto:shivipm...@gmail.com] Sent: Tuesday, July 26, 2016 10:08 AM To: David L Carlson Subject: Re: [R] Date Time in R Hi David, This gives the results accurately. The first line shows all the variable

Re: [R] Date Time in R

2016-07-26 Thread David L Carlson
Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi Bhatia Sent: Tuesday, July 26, 2016 7:42 AM To: Marc Schwartz Cc: R-help Subject: Re: [R] Date Time in R Thanks Marc for the help. thi

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Thanks Marc for the help. this really helps. I think there is some issue with the data saved in csv format for this variable as when i checked: str(eir$date)- this results in :- Date[1:5327], format: NA NA NA NA NA. Thanks again. On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz wrote: > Hi, > > T

Re: [R] Date Time in R

2016-07-26 Thread Marc Schwartz
Hi, That eir$date might be a factor is irrelevant. There is an as.Date() method for factors, which does the factor to character coercion internally and then calls as.Date.character() on the result. Using the example data below: eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hello Again, While i tried your solution as you suggested above it seems to be working. Here is the output temp<- dput(head(eir$date)) c("05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16") however it still shows class(eir$date) as character and hence i cannot find weekdays from

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Thanks Duncan for the quick response. I will check again as you suggested. If that doesn't work i will share a reproducible example. Thanks again On Tue, Jul 26, 2016 at 4:43 PM, Duncan Murdoch wrote: > On 26/07/2016 7:05 AM, Shivi Bhatia wrote: > >> Hi Team, >> >> This scenario may have co

Re: [R] Date Time in R

2016-07-26 Thread Duncan Murdoch
On 26/07/2016 7:05 AM, Shivi Bhatia wrote: Hi Team, This scenario may have come across a number of times however i checked nabble & SO and couldn't find a solution hence request assistance. I have a date variable in my data-set eir. The class of this var was character while i had read the file

[R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hi Team, This scenario may have come across a number of times however i checked nabble & SO and couldn't find a solution hence request assistance. I have a date variable in my data-set eir. The class of this var was character while i had read the file in r studio. Example of date - 05-30-16 To c