>>
>>>>> > So this looks correct so far.
>>>>> >
>>>>> >
>>>>> >
>>>>> > # convert strings (or factors) to a date object
>>>>> >
>>>>> > a1$date <- as.Date(a1$date, “%m-%d-%y”)
>
)
>>>> >
>>>> >
>>>> >
>>>> > # Note the date object is now displayed in the format %Y-%m-%d by
>>>> default
>>>> >
>>>> > # so no need for the mdy() or ymd() function
>>>> >
>>
; # so no need for the mdy() or ymd() function
>>> >
>>> >
>>> >
>>> > # extract the weekdays as number
>>> >
>>> > weekdays <- wday(a1$date)
>>> >
>>> >
>>> >
>>> > #
y(a1$date)
>> >
>> >
>> >
>> > # note can’t have spaces in variable names
>> >
>> > week_names <- wday(a1$date, label=TRUE)
>> >
>> >
>> >
>> >
>> >
>> > *From:* Shivi Bhatia [mail
gt; # 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 <
bel=TRUE)
>
>
>
>
>
> *From:* Shivi Bhatia [mailto:shivipm...@gmail.com]
> *Sent:* July 26, 2016 12:16 PM
> *To:* Tom Wright <t...@maladmin.com>
> *Cc:* David L Carlson <dcarl...@tamu.edu>; r-help <r-help@r-project.org>
>
> *Subject:* Re: [R] Da
<r-help@r-project.org>
*Subject:* Re: [R] Date Time in R
Hello Tom,
Please find the details: (i have changed name from eir to a1, rest all is
same)
str(a1$date)
Factor w/ 32 levels "05-30-16","05-31-16",..: 1 1 1
head(a1$date)
05-30-16 05-30-16 05-30-16 05-30-16 05-
016 11:46 AM
> To: David L Carlson <dcarl...@tamu.edu>
> Cc: r-help <r-help@r-project.org>
> 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
>
u
>> created with read.csv() and show 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
>>
&g
-help-boun...@r-project.org] On Behalf Of Shivi Bhatia
Sent: July 26, 2016 11:46 AM
To: David L Carlson <dcarl...@tamu.edu>
Cc: r-help <r-help@r-project.org>
Subject: Re: [R] Date Time in R
Hi David please see the code and some reproducible data:
eir$date<- as.Date(eir$date,format = &quo
lson <dcarl...@tamu.edu>
>> wrote:
>>
>> What does this produce?
>>
>> > readLines("YourCSVfilename.csv", n=5)
>>
>> If the data are in Excel, the date format used in .csv files is not
>> always in the same as the format use
d with read.csv() and show 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
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 sugg
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
Anthropology
Texas A 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. this re
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
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",
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
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,
>>
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
Hi Arun,
Thank u so much for your help. It helped me solve the problem
THANK YOU
-Yashvardhan Kajaria
On Thu, Mar 14, 2013 at 11:28 PM, arun smartpink...@yahoo.com wrote:
HI,
1.
date1-c(5 jan 2013, 1 jan 2013)
date1-as.Date(date1,format=%d %b %Y)
date1[1]-date1[2]
#Time difference of 4
A good place to start might be http://www.jstatsoft.org/v40/i03/paper for the
lubridate package or have a look at the zoo package
John Kane
Kingston ON Canada
-Original Message-
From: yash.kaja...@gmail.com
Sent: Thu, 14 Mar 2013 19:15:00 +0530
To: r-help@r-project.org
Subject:
On Thu, Mar 14, 2013 at 9:45 AM, yash kajaria yash.kaja...@gmail.com wrote:
Hi,
I wanted to learn how to solve a date and time manipulation where i can
do the following two
1. difference of two dates eg (differnce between 5th jan 2013 and 1st
jan 2013)
2.Suppose i have week
HI,
1.
date1-c(5 jan 2013, 1 jan 2013)
date1-as.Date(date1,format=%d %b %Y)
date1[1]-date1[2]
#Time difference of 4 days
2.
If you only have the week number of year without any other information, it
would be difficult to predict which day that would be.
You could get the week number from
24 matches
Mail list logo