Displaying 20 results from an estimated 4000 matches similar to: "number of days"
2004 Jun 07
7
Vectors of years, months, and days to dates?
The interface for dates in R is a little confusing to me.
I want to create a vector of Date objects from vectors of years, months, and
days.
One solution I found is:
years <- c(1991, 1992)
months <- c(1, 10)
days <- c(1, 2)
dates <- as.Date(ISOdate(years, months, days))
But, in this solution the ISOdate function converts the vectors into
characters,
which can cause serious
2007 Jan 25
2
Days of the week?
Hi WizaRds,
What is the "standard" way to get the day of the week from a date such 
as as.Date("2006-12-01")? It looks like fCalendar has some functions
but this requires a change in the R locale to GMT. Is there another way?
Thanks!
Jack.
 
---------------------------------
Be a PS3 game guru.
	[[alternative HTML version deleted]]
2002 Oct 28
1
as.POSIX (PR#2222)
Full_Name: Alec Stephenson
Version: 1.6.0
OS: linux
Submission from: (NULL) (148.88.138.5)
Appears to be a sign error in as.POSIX(lt/ct)
> library("chron")
The following is fine, with default origin.
> tmp <- chron(1:2, origin = c(1,1,1970))
> as.POSIXlt(tmp)
[1] "1970-01-02 01:00:00 GMT" "1970-01-03 01:00:00 GMT"
These are not.
> tmp <-
2002 Feb 02
1
chron problem: extracting days and years
Hello r-help,
I'm trying to split a character vector of dates of the form "dd-mmm-yy" 
into component days, months and years. But
 > library(chron)
 > testdate<-as.POSIXlt(strptime("17-Sep-98","%d-%b-%y"))
 > testdate
[1] "1998-09-17"
 > months(testdate)
[1] "September"    # which is fine, but for days and years I get
 >
2006 Aug 10
2
day, month, year functions
Hi list, 
I'm trying to turn a date into something productive. (Not what you may be thinking....) 
I want three functions so I could take a "date" object and get the day of week, month, and year from it.
xx <- as.Date("2006-01-05") 
month(xx) equal 1
day(xx) equal 5
year(xx) equal 2006
I'm aware of the weekdays() and months() functions in the base package. But
2011 May 14
2
changing the day of the week in dates format
Dear all,
I have a question related to the POSIXlt function in R.
I have a set of dates and times, for exmaple:
startx <- as.POSIXct("2011-01-01 00:00:00")
finx <- as.POSIXct("2011-12-31 00:00:00")
daysx<- seq(startx, finx, by="24 hours")
I
 want to change the dates of all the days falling on a Saturday to the 
next working day (i.e. Monday). So I
2007 Aug 07
4
Number of days in each month
Hi R-users,
What is the best way to achieve a table which contains all days and months
between years 2007-2020? I would like to calculate number of days in each
month within those years (to data frame).
Regards,
Lauri
	[[alternative HTML version deleted]]
2012 Oct 30
2
changing date by +/- days
Hi, 
Let say I have a date variable like this:
structure(1243792800, class = c("POSIXct", "POSIXt"), tzone = "GMT")
[1] "2009-05-31 18:00:00 GMT"
How can I make it 10 days prior, so:
[1] "2009-05-21 18:00:00 GMT"
I'm randomly selecting dates from a list  and want a  second value a set #
of days either before or after. 
Thanks ahead of time.
2007 Feb 20
1
Reshape (pivot) question
Hi R-users,
I have a data set like this (first ten rows):
    id patient_id date code class eala ID1564262 1562 6.4.2006 12:00 5555 1
NA ID1564262 1562 6.4.2006 12:00 5555 1 NA ID1564264 1365 14.2.2006 14:35
5555 1 50 ID1564265 1342 7.4.2006 14:30 2222 2 50 ID1564266 1648 7.4.200614:30
2222 2 50 ID1564267 1263 10.2.2006 15:45 2222 2 10 ID1564267 1263
10.2.200615:45
3333 3 10 ID1564269 5646
2011 May 24
2
Extracting day of month from Date objects
I've always found the chron library to be useful for
tasks like this:
> x <- round(runif(10)*100000, digits=0)
> y <- as.Date(x, origin="1970-01-01")
> library(chron)
> days(y)
  [1] 7  25 26 25 10 24 1  31 12 8 
31 Levels: 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < ... < 31
Notice that it returns the days as
2013 Dec 02
1
Days to solstice calculation
Hello,
I've come across a problem in developing a set of custom functions to calculate the number of hours of daylight at a given latitude, and the number of days a date precedes or secedes the summer solstice. I discovered an inconsistency concerning leap years between my derived values and those from the US naval databases. It seems as far as I can figure that my inconsistency arises either
2004 Jun 14
4
Quirks with system.time and simulations
I tried the code that Richard O'Keefe posted last week, to wit:
library(chron)
    ymd.to.POSIXlt <-
        function (y, m, d) as.POSIXlt(chron(julian(y=y, x=m, d=d)))
    n <- 100000
    y <- sample(1970:2004, n, replace=TRUE)
    m <- sample(1:12,      n, replace=TRUE)
    d <- sample(1:28,      n, replace=TRUE)
    system.time(ymd.to.POSIXlt(y, m, d))
    [1]  8.78  0.10
2016 Dec 06
6
segfault with POSIXlt zone=NULL zone=""
Hi all,
I ran into a segfault while playing with dates.
    $ R --no-init-file
    ...
    > library(lubridate); d=as.POSIXlt(floor_date(Sys.time(),"year")); d$zone=NULL; d$zone=""; d
    Attaching package: ?lubridate?
    The following object is masked from ?package:base?:
        date
    Warning message:
    package ?lubridate? was built under R version 3.4.0 
    
2020 Oct 01
3
timezone tests and R-devel
The return value of Sys.time() today with a timezone of US/Eastern is
unchanged between 4.0.3-patched and devel, but on devel the following test
fails
  all.equal(x, as.POSIXlt(x))
with
  x = Sys.time()
This means that devel does not complete make tests (failure on
tests/reg-tests-2.R)
It is entirely possible that it is an error on my end, I use
  export TZ="US/Eastern"
but I have been
2006 Sep 01
3
Date conversion with as.POSIXct and as.POSIXlt (PR#9196)
Full_Name: Erich Neuwirth
Version: 2.3.1
OS: Windows XP, Linux
Submission from: (NULL) (131.130.135.167)
Converting Sys.Date() to a POSIX compliant time type in different ways 
produces inconsistent results:
> Sys.date()
[1] "2006-09-01"
> as.POSIXct(Sys.Date())
[1] "2006-09-01 02:00:00 CEST"
> as.POSIXlt(Sys.Date())
[1] "2006-09-01"
>
2011 Mar 24
5
subset and as.POSIXct / as.POSIXlt oddness
Dear R users,
Given this data:
x <- seq(1,100,1)
dx <- as.POSIXct(x*900, origin="2007-06-01 00:00:00")
dfx <- data.frame(dx)
Now to play around for example:
subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00"))
Ok. Now for some reason I want to extract the datapoints between hours
10:00:00 and 14:00:00, so I thought well:
subset(dfx, dx >
2016 Dec 06
1
segfault with POSIXlt zone=NULL zone=""
>>>>> Joshua Ulrich <josh.m.ulrich at gmail.com>
>>>>>     on Tue, 6 Dec 2016 09:51:16 -0600 writes:
    > On Tue, Dec 6, 2016 at 6:37 AM,  <frederik at ofb.net> wrote:
    >> Hi all,
    >> 
    >> I ran into a segfault while playing with dates.
    >> 
    >> $ R --no-init-file
    >> ...
    >> >
2020 Oct 23
2
The presence/absence of `zone` in POSIXlt depending on time zone as a cause of possible inconsistences?
Dear all,
I have just detected what seems a minor inconsistence with data types. If one unlists a POSIXlt time with GMT zone gets a numeric vector, since the POSIXlt list has no `zone` element, while if one unlists a POSIXlt time with a non GMT zone (also non specifying tz if the Sys.timezone is not GMT) gets a character vector due to including the `zone` element.
> x <-
2011 Feb 04
2
terribly annoying bug with POSIXlt : one o'clock is midnight?
Apparently, as.POSIXlt takes one o'clock as the start of the day :
> as.POSIXlt(0,origin="1970-01-01")
[1] "1970-01-01 01:00:00 CET"
> as.POSIXlt(0,origin="1970-01-01 00:00:00")
[1] "1970-01-01 01:00:00 CET"
> as.POSIXlt(0,origin="1970-01-01 23:59:59")
[1] "1970-01-02 00:59:59 CET"
Cheers
-- 
Joris Meys
Statistical
2012 Feb 24
6
strange behaviour of "POSIXlt" "POSIXt" object
Hi, 
Does anybody know why get I this kind of strange situation:
Browse[2]> hcEnd
[1] "2009-03-29 06:30:00"
Browse[2]> class(hcEnd)
[1] "POSIXlt" "POSIXt" 
Browse[2]> is.na(hcEnd)
[1] TRUE
This issue is the source of my all issues in my program, 
Thanks for your help
--
View this message in context: