Skip to content

changing the day of the week in dates format

4 messages · Dave Evens, Adrian Duffner, jim holtman

#
Hi Dave,

your problem is that you are working with a S3 class, what is mainly a 
list with naming convention. Hence it is possible to change just one 
entry of the list, but it is nearly never recommendable.

So a slight change to your code should provide you the required output:
 > mydaysx[select] <- mydaysx[select] + 2*24*60*60
 > select <- mydaysx$wday==6
 > sum(select)
[1] 0

In this case not only the entry $mday of the list is changed, but the 
whole object is updated.

Cheers
Adrian

Am 14.05.2011 20:44, schrieb Dave Evens:
#
What is it that you want to do?  If you move the dates forward a year,
then what does it mean to add one year to 2/29/2008?  You did mention
accounting for leap year.  It goes the other way with 2/28/2007 and
3/1/2007; what is your expectation in these cases?  You can always
convert everything to characters and then substring out the year and
put the new one in, and then check for the leap year condition and do
the appropriate action.

The equation that you used would add 6 hours to each each succeeding
year's date.

So I ask my favorite question:  "what is the problem that you are
trying to solve?"
On Sun, May 15, 2011 at 11:13 AM, Dave Evens <daveevens1 at yahoo.co.uk> wrote: