search for: date1

Displaying 20 results from an estimated 86 matches for "date1".

Did you mean: date
2012 Nov 10
4
help on date dataset
...7/04/2009 usa 40 12 27/04/2009 Mexique 26 13 27/04/2009 Canada 6 14 27/04/2009 Spain 1 15 28/04/2009 Canada 6 I want to create something like that: ? When entering two dates date1,date2 in the fuction extraction. The result must be: a new subdata with one line per date , per PAYS,per nb_pays.ILI (by summing all the number in variable nb_pays.ILI per date,per country) and the date must be between date1 and date2. I sart to do somethings like that extraction=function(date...
2009 Jul 11
2
Date conversions
...up as 2020 after conversion. That's just wrong. 2) Sometimes I get NAs. That I don't understand. Can anyone see what I'm doing wrong here? As I say, I think I'd like to convert 01/03/2004 into 1040103 as this numeric format seems very good for doing comparisons. The code: MyDate1 = read.csv("C:\\Date1.txt",header=TRUE) MyDate2 = read.csv("C:\\Date2.txt",header=TRUE) MyDate1 Date1 = MyDate1$Date class(Date1) mode(Date1) Date1 Date1 = as.Date(Date1, "%m/%d/%y") class(Date1) mode(Date1) Date1 MyDate2 Date2 = MyDate2$EnDate class(Date2) mode(Dat...
2008 Jan 02
3
Find missing days
Hi, I have a data.frame like this: y <- rnorm(60) lev <- gl(3,20, labels=paste("lev", 1:3, sep="")) date1 <- as.Date(seq(ISOdate(2007,9,1), ISOdate(2007,11,5), by=60*60*24)) date1 <- date1[-c(3,4,15,34,38,40)] df <- data.frame(lev=lev, date1=date1, y=y) I would like to produce a new data.frame with missing days in df$date1 in each df$lev, like this: lev date1 1 lev1 2007...
2005 Feb 24
2
Row median of Date class variables in a data frame
...a frame consist of columns of class Date. Below are my test data and best attempt at using apply. I didn't see a solution via Google or the Baron search site. I'd be grateful for any suggestions or solutions. I'm using R 2.0.0 on Mac OS X. Thank you, Stephen Weigand ### Test data date1 <- c(1000, 2000, 3000,4000) date2 <- date1 + 100 date3 <- date2 + 100 class(date1) <- class(date2) <- class(date3) <- "Date" test <- data.frame(date1, date2, date3) print(test) ### create a function for apply() medDate <- function(x){ obj <- unclass(unlis...
2009 Jan 21
3
Error as.Date on Invalid Dates
Hi All, I have an script in R which accepts user inputs for certain parameters, particularly dates, which the user inputs as character strings. eg: > date1 <- "2009-01-21" The script later parses the input via the as.Date function: > as.Date(date1) However, as.Date encounters an error when the string does not represent an actual date. eg: > date1 <- "2009-02-29" # Note: 2009 not a leap year > as.Date(date1) Error...
2013 Feb 13
3
date and matrices
Hi Elisa, Try this: date1<-format(seq.Date(as.Date("1991.1.1",format="%Y.%m.%d"),as.Date("1996.12.31",format="%Y.%m.%d"),by="day"),"%Y.%m.%d") ?length(date1) #[1] 2192 mat1<-matrix(c(.314,.314,.273,.273,.236,.236,.236,.236,.273,.314,.403,.314),ncol=1) res1&lt...
2006 Dec 28
3
Dates in R
...omebody point me to references or provide some code on dealing with this date issue. Basically, I have two vectors of values that represent dates. I want to convert these values into a date format and subtract the differences to show elapsed time in days. More specifically, here is the example: Date1 Date2 032398 061585 032398 061585 111694 101994 111694 101994 062695 021595 051898 111597 072495 040195 072495 040195 The dates are in the mmddyy format, but when I attempt to format these in R with the function, date.mmddyy(Date1), I get very odd results. Any help on...
2015 Nov 06
0
Puzzled by eval
...est of the search list. In code sourced to the global environment, only the third of these is searched. Since base is in the second one, it is found first in the package version. Duncan Murdoch > > Terry Therneau > > > code: > joe <- function(id, data, subset, na.action, date1, date2, other.args) { > Call <- match.call() > if (!missing(data)) temp <- fred(Call) > > temp > } > > fred <- function(Call) { > # get a first copy of the id and date variables > index <- match(c("id", "date1"...
2013 Feb 19
1
data format
Hi, Try this: el<- read.csv("el.csv",header=TRUE,sep="\t",stringsAsFactors=FALSE) ?elsplit<- split(el,el$st) ? datetrial<-data.frame(date1=seq.Date(as.Date("1930.1.1",format="%Y.%m.%d"),as.Date("2010.12.31",format="%Y.%m.%d"),by="day")) elsplit1<- lapply(elsplit,function(x) data.frame(date1=as.Date(paste(x[,2],x[,3],x[,4],sep="-"),format="%Y-%m-%d"),discharge=x[,...
2015 Nov 06
4
Puzzled by eval
...eful with envr and enclos arguments -- how does base end up earlier in the search path? Perhaps this is clearly stated in the docs and just not clear to me? A working solution to the dilemma is of course more than welcome. Terry Therneau code: joe <- function(id, data, subset, na.action, date1, date2, other.args) { Call <- match.call() if (!missing(data)) temp <- fred(Call) temp } fred <- function(Call) { # get a first copy of the id and date variables index <- match(c("id", "date1", "date2"), names(Call), nomatch=0)...
2008 Jun 29
1
Calculating quarterly statistics for time series object
I have time series observation on daily frequencies : library(zoo) SD=1 date1 = seq(as.Date("01/01/01", format = "%m/%d/%y"), as.Date("12/31/02", format = "%m/%d/%y"), by = 1) len1 = length(date1); data1 = zoo(matrix(rnorm(len1, mean=0, sd=SD*0.5), nrow = len1),  date1) plot(data1) Now I want to calculate 1. Quarterly statistics like...
2009 Dec 09
1
reshape() makes R run out of memory (PR#14121)
Full_Name: Alexander L. Belikoff Version: 2.8.1 OS: Ubuntu 9.04 (x86_64) Submission from: (NULL) (67.244.71.200) I'm trying to reshape the following data frame: ID DATE1 DATE2 VALUE_TYPE VALUE 'abcd1233' 2009-11-12 2009-12-23 'TYPE1' 123.45 ... VALUE_TYPE is a string and is a factor with only 2 values (say TYPE1 and TYPE2). I need to transform it into the following data frame ("wide" tr...
2012 May 12
1
Query regarding date as argument in functions - and about sqldf
Hi, I have a query about sqldf, and dates in general. I couldnt find much on the net or on the forums, hence I am here. Here is the issue: I want to write a function that accepts 3 arguments: date1, date2 and a dataframe, say 'df'. Within the function, I want to populate a temp dataframe which essentially contains the output of the query "select * from df where DATE between date1 and date2". DATE is a column (of class Date) which will be present in the input dataframe. This...
2005 Sep 22
1
problem with dates
...to convert a vector of dates into julian dates using the following commands: as.date & as.numeric. I can convert a date no problem by doing the following: as.numeric (as.date ("9/21/2004")) but as soon as I try to do an entire vector I am given the following: as.numeric (as.date(date1)) Error in as.date(date1) : Cannot coerce to date format I have tried starting with a number of different date formats including dd/mm/yy, dd/mm/yyyy, month, day, year.. Following is a sample of the vector of dates that I am using: > date1 [1] 7/1/2005 4/27/2005 7/15/2004 11/30/2004 1/8...
2012 Mar 07
1
date columns chooser
i have a data frame with 2 columns of dates. with str(dataframe) i have ensured myself that they were indeed formatted as dates. one column has NA's in it. the aim is now to make a third column that chooses date1 if it is a date, and choose date2 if it is a NA. i am trying df$date3=ifelse(is.na(df$date1), df$date2, df$date1). this leads to unexpected behaviour: the resulting column is numeric, and shows numbers like 16000. i have no idea what this is and how to solve it? henk [[alternative HTML versio...
2013 Oct 15
2
Data handling
...ave a vector in a format year-month-day hh:mm:ss.0000. Or, in format: format = "%F %H:%M:%OS4", as POSIXct class. I made the the conversion step-by-step to have sure that nothing is missed in the way: > options (digits.sec = 4) > getOption ("digits.sec") [1] 4 > teste$Date1 = as.Date (teste$Date, format = "%m/%d/%y") > class (teste$Date1) [1] "Date" > teste$Fraction = sub ("0.", "", teste$Fraction) > teste$TimeC = paste (teste$Time, teste$Fraction, sep = ".") > teste$TimeCC = paste (teste$Date1, teste$TimeC...
2013 Apr 13
2
Comparison of Date format
Hi, ?In the example you provided, it looks like the dates in Date2 happens first.? So, I changed it a bit.? DataA<- read.table(text=" ID,Status,Date1,Date2 ??? ??? ?????? 1,A,3-Feb-01,15-May-01 ??? ??? 1,B,15-May-01,16-May-01 ??? ??? 1,A,16-May-01,3-Sep-01 ??? ??? ??? ??? ??? 1,B,3-Sep-01,13-Sep-01 ??? ??? ??? ??? ??? 1,C,13-Sep-01,26-Feb-04 ??? ??? ??? ??? ??? 2,A,9-Feb-01,24-May-01 ??? ??? 2,B,24-May-01,25-May-01 ??? ??? ??? ??? ??? 2,...
2006 Apr 17
1
Function for computing the difference between 2 dates in months
Folks: With the help of David L. Reiner, I've developed a function that computes the number of months between 2 dates, x and y. num.months <- function ( x , y ) { x <- as.Date( x ) y <- as.Date( y ) seeq <- seq(from=x , to=y , by="months") ans <- length( seeq ) - 1 if ( max( seeq) > y ) ans <- ans -1 ans } To ease your reading this function, I've
2006 Apr 19
0
Function for computing the difference between 2 dates inmonths
...alf Of Ana Patricia Martins Sent: Wednesday, April 19, 2006 8:45 AM To: Smith, Phil Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Function for computing the difference between 2 dates inmonths Hi, I tried to apply the function you developed to my data file, which had to be created as follows: date1<-sub(' - - ','',paste(substring(ie[,],257,260),substring(ie[,],255,256),substring(ie[,] ,253,254),sep="-")) Your functions works well only in example #1 but when I applied a "cycle" (if clause) doesn't work (example #2 and #3). Example #1: a35641<...
2011 Aug 07
1
all.equal doesn't work for POSIXlt objects
Hi all, following sample code illustrates the problem : Date1 <- Date2 <- as.POSIXlt(seq.Date(as.Date("2010-04-01"),as.Date("2011-04-01"),by='day')) identical(Date1,Date2) all.equal(Date1,Date2) identical() gives the correct answer. As there is no all.equal method for POSIXlt objects, all.equal.list is used instead. Subs...