Skip to content

date & time manipulation- R 2.15.1 windows 7

5 messages · John Kane, Gabor Grothendieck, arun +1 more

#
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
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
#
On Thu, Mar 14, 2013 at 9:45 AM, yash kajaria <yash.kajaria at gmail.com> wrote:
Try this:
Time difference of 4 days
[1] 4

The year and week don't imply the day of the week.  We can input the
year, week number and day of the week to get the date:
[1] "2013-01-06"


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
#
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 the date:
library(lubridate)
?date2<-"2013-01-26"
wday(ymd(date2),label=TRUE)
# 1 parsed with %Y-%m-%d
#[1] Sat


week(ymd(date2))
# 1 parsed with %Y-%m-%d
#[1] 4
A.K.

----- Original Message -----
From: yash kajaria <yash.kajaria at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Thursday, March 14, 2013 9:45 AM
Subject: [R] date & time manipulation- R 2.15.1 windows 7

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 number of the year, i want to know if i can find
out the day it refers to eg( say week 2 of 2013 would be? 6th jan 2013 and
the day is sunday)
? ? ?  i need my result to tell me that its the 6th of jan 2013 as well as
the day (sunday)

Can u please help me out?

Thanks,
Yashvardhan Kajaria

??? [[alternative HTML version deleted]]

______________________________________________
R-help at 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.
3 days later