Re: [R] date time manipulation- R 2.15.1 windows 7

2013-03-18 Thread yash kajaria
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 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.kaja...@gmail.com
 To: r-help@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@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.


[R] date time manipulation- R 2.15.1 windows 7

2013-03-14 Thread yash kajaria
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@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] date time manipulation- R 2.15.1 windows 7

2013-03-14 Thread John Kane
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: [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@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.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
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] date time manipulation- R 2.15.1 windows 7

2013-03-14 Thread Gabor Grothendieck
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 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)

Try this:

 dif - d - as.Date(cut(d, year))
 dif
Time difference of 4 days
 as.numeric(dif)
[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:

 year - 2013
 week - 2
 day - Sun
 as.Date(paste(year, week-1, day), %Y %W %a)
[1] 2013-01-06


--
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
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] date time manipulation- R 2.15.1 windows 7

2013-03-14 Thread arun
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.kaja...@gmail.com
To: r-help@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@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.