Displaying 20 results from an estimated 20000 matches similar to: "Extracting day of month from Date objects"
2010 Jun 29
3
formating chron date times for printing
the date were created with chron with this argument
format=c(dates="Y/m/d", times="H:M:S"))
so I have the dates being displayed as
(10/06/22 12:00:00)
I would like to have them displayed as
"2010-06-22 12:00:00" or "%Y-%m-%d %H:%M:%S"
and then I can convert these for mergeing with another data frame
x <- (structure(c(14464, 14464.0104166667,
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
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
2003 Dec 15
3
Julian Dates
Hi,
I'm a bit confused how julian() works. If I understand right, it returns
the number of days since the origin.
I have a vector:
> SLDATX[1:10]
[1] "1986-01-06" "1986-01-17" "1986-02-02" "1986-02-04"
[5] "1986-02-04" "1986-02-21" "1986-03-06" "1986-03-25"
[9] "1986-04-06"
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
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
>
2003 Nov 26
4
strptime Usage
Hi,
I have a column in a dataframe in the form of:
> as.vector(SLDATX[1:20])
[1] "1/6/1986" "1/17/1986" "2/2/1986" "2/4/1986" "2/4/1986"
[6] "2/21/1986" "3/6/1986" "3/25/1986" "4/6/1986" "4/10/1986"
[11] "4/23/1986" "4/30/1986" "5/8/1986"
2004 Feb 14
2
converting data to date format
Dear all,
I import my data from a csv-file containing one row with date-entries. How
can I tell R to treat this data as dates?
I've tried to bring it in character-format (as.charachter()) followed by
as.POSIXlt() but I get an error message, that the character string is not in
a standard unambiguous format, although the date is of format yyyy-mm-dd
(what is standard format according to R
2012 Sep 16
1
possible TZ bug in parseISO8601 - "Error in if (length(c(year, month, day, hour, min, sec)) == 6 && c(year, : [...]"
Hey all,
Virgin post to this list - hope I've got it right ;o)
I've been learning R intensively the last two weeks and gone from newbie
status to *reasonably* comfortable with it.
Here's an issue I just cannot solve however as it appears to be some kind
of bug in R itself. But I won't claim that for sure.
I have a function as follows:
FindHighRow <- function(searchVector,
2004 Mar 01
6
Find out the day of week for a chron object?
I know that this is correct:
library(chron)
x = dates("01-03-04", format="d-m-y", out.format="day mon year")
print(x)
It gives me the string "01 Mar 2004" which is correct.
I also know that I can say:
print(day.of.week(3,1,2004))
in which case he says 1, for today is monday.
My question is: How do I combine these two!? :-) I have a
2013 Feb 19
5
Converting the data in year month day hour and minutes to date
Hi ,
I am trying to convert the date as factor to date using "as.date" function
in R. I have the date in the following format
2008-01-01 02:30
I tried to use the following command :
as.Date(mydata$Date, format="%y-%m-%d ")
Can somebody help me with this ? I was able to convert the format with no
hour but getting difficulty with hour included.
Thank you.
2011 Apr 06
1
Problem to convert date to number
Hi R users,
I have a maybe small problem which I cannot solve by myself.
I want to convert
"chron" "dates" "times"
(04/30/06 11:35:00)
to a number with as.POSIXct.
The Problem is that I can't choose different timezones. I always get "CEST"
and not "UTC" what I need.
date = as.POSIXct(y,tz="UTC")
"2006-04-30 11:35:00
2010 Oct 29
7
date calculation
Hi list,
Could someone explain to me why the following result is not a integer?
> difftime(strptime("24NOV2004", format="%d%b%Y"), strptime("13MAY2004",
>format="%d%b%Y"), units="days")
Time difference of 195.0417 days
I'm using R2.12.0 on WinXP.
Thanks!
...Tao
2014 Jul 09
4
Conversion date a numeric y vuelta a date
Hola a todos:
Debe de ser una tonterĂa, pero no consigo saber porque la siguiente linea
no devuelve la fecha actual:
as.Date(as.numeric(Sys.time()))
He hecho esa prueba porque no consigo pasar un numero convertido a partir
de una fecha y modificado a fecha de nuevo.
Gracias por adelantado.
Un saludo,
Alberto.
[[alternative HTML version deleted]]
2003 Nov 12
3
Chron, as.POSIXct problem
Dear R list,
I noticed the following 'problem' when changing the format of dates
created with seq.dates() (from the Chron library) using as.POSIXct()
(R 1.8.0 on OSX 10.2.8):
> datesTest<-seq.dates(from="10/01/1952", length=3, by="days");
> datesTest
[1] 10/01/52 10/02/52 10/03/52
# Now changing the format to show year as 1952.
>
2012 Jun 15
2
time zones and the chron to POSIXct conversion
Hey R folks,
i found some strange (to me) behaviour with chron to POSIXct conversion.
The two lines of code result in two different results, on ewith the
correct time zone, one without:
library(chron)
as.POSIXct(chron('12/12/2000'), tz = 'UTC')
as.POSIXlt(chron('12/12/2000'), tz = 'UTC')
Only the code below would give me a POSIXct object with the correct time
2008 Aug 01
1
chron objects: input/output
Hi list, I have some questions regarding
1) conversion of date + time characters to chron
2) formatting chron object printing
Regarding (1), Gabor's Rnews 2004 4/1 article has been indispensible,
but I often work with files where dates and times are contained in a
single field. In this case, I would like to control input/output of
chron objects when each observation of date and time is
2004 Jun 16
3
Aggregating on Water Year Rather Than Calendar Year
The US water year extends from 01 October yyyy-1 through 30 September yyyy
and is referenced by the year starting on the included 01 January yyyy.
I'd like to be able to find the annual means for the water year. To do so
I've taken the input date-time, which is in the usual format
"1991-10-07 10:35:00"
changed it by:
w$d<-as.POSIXct(w$date.time)
Now I can add an
2008 Nov 27
2
Troubles with the format of dates
Dear useRs,
I'm struggling again with date-related stuff: I am using R to draw water levels at certain measuring
stations. My data comes as a tab-delimited text file and looks like this:
DATUM P1 P2
...
2006-11-16 425.21 423.99
2006-12-15 425.12 423.97
2007-01-16 425.16 424.06
...
(measurements started in July 2004 and still continue on a monthly or bi-weekly basis)
This