similar to: years from as.POSIXlt

Displaying 20 results from an estimated 6000 matches similar to: "years from as.POSIXlt"

2011 Jan 30
4
Extract time only from POSIXlt object
How can I extract only the time component from an POSIXlt object? For example if I try the following it still returns both the date and time... >as.POSIXlt(tr.date[1]) [1] "2010-10-18 21:46:53" >as.POSIXlt(tr.date[1],"%H:%M:%S") [1] "2010-10-18 21:46:53" round and trunc don't help... is there an "as.Time" equivalent to as.Date ? Thanks,
2004 Feb 06
2
vector of factors to POSIXlt
hello, I have a vector of factors > str(rcptdt) Factor w/ 51 levels "1/10/03","1/13/03",..: > length(rcptdt) [1] 87 which i want to convert to class POSIXlt to extract the day, so: a1<-format(rcptdt,"%m/%d/%y") > length(a1) [1] 87 and: a2<-strptime(a1, "%m/%d/%y") str(a2) `POSIXlt', format: chr [1:87] "2002-04-18"
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
2010 Dec 10
2
Remove 100 years from a date object
Hello, I have some data that has dates in the form 27.02.37. I convert them to a date object as follows: as.Date(data$date,format="%d.%m.%y") But this gives me years such as 2037 when I would like them to be 1937. I thought of trying to take off some time i.e. as.Date(camCD$DoB,format="%d.%m.%y") - 100*365 But that doesn't seem to work out correctly. Any ideas how to
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 >
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
2011 Mar 08
1
Date arithmetic coerces POSIXlt to POSIXct?
Hi. This feels like a bug to me, or at least an undocumented feature, but I thought I'd see what people here thought of it. Consider a POSIXlt object like this one: > a <- as.POSIXlt ("2011-01-23 12:45:45") > class (a) [1] "POSIXlt" "POSIXt" Fine. Now, if I do some arithmetic on that object, the result is converted to POSIXct. > class (a
2009 Mar 31
2
TimeWithZone seems in rails 2.3 seems broken...is this the correct behavior?
My environment.rb contains config.time_zone = ''UTC'' If my understanding is correct, rails should assume time values coming from the database are UTC, and since config.time_zone is set to ''UTC'', it should not try to convert the times. Instead, rails is assuming that the db values are Eastern (my local zone) and is incorrectly adding four hours to convert to
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
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
2008 Apr 11
1
Error in fromchar(as.character(x)) : character string is not in a standard unambiguous format
Hello, I was hoping for advice regarding resolving the above error. I have a csv file that contains the following variable: $ Order.Made.Date : Factor w/ 299 levels "1-Apr-08","1-Aug-05",..: 278 285 91 286 159 132 108 261 282 147 ... I want to calculate a variable named F.length, which is today's date minus the values contained in the variable:
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 >
2005 Apr 30
1
segfault during build of 2.1.0 on RH9; print.POSIXct implicated (PR#7827)
In attempting to build R using rpmbuild --rebuild R-2.1.0-0.fdr.2.fc3.src.rpm on a fairly up-to-date RedHat 9 system (that is, with patches installed through May 1 2004), it failed at the make check-all step. The problem was reproducible by going into the tests directory and make test-Segfault The last lines of the saved file no-segfault.Rout.fail are > > ## c.POSIXct : > >
2009 Jan 21
1
Looking for a special date function in R
Hello, everyone I wonder if R has something similar to Excel function EDATE(start_date; months) which returns a serial number of the date that is the indicated number of months before of after the start date. Example (the second column EDATE(first_column; -6)): 01.01.1999 01.07.1998 02.02.1999 02.08.1998 06.03.1999 06.09.1998 I am working with a zoo object where the row names are dates and for
2008 Dec 02
1
match
Hi, I would like to check which rows of 'types.prev' matrix pop up in 'types', following R in-built procedure. I tried 'match' function but it works in case of the one dimensional vectors. Will appreciate any suggestions. best, robert > types edate K [1,] 20060819 12.5 [2,] 20060819 17.5 [3,] 20060819 22.5 [4,] 20070217 12.5 [5,] 20060617 10.0
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
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. >
2004 Aug 17
3
Fwd: strptime() problem?
Hi all; I've already send a similar e-mail to the list and Prof. Brian Ripley answered me but my doubts remain unresolved. Thanks for the clarification, but perhaps I wasn't clear enough in posting my questions. I've got a postgres database which I read into R. The first column is Timestamp with timezone, and my data are already in UTC format. An 'printed' extract of R
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"
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