Displaying 17 results from an estimated 17 matches for "datediffer".
Did you mean:
datediff
2017 Jun 03
4
New var
Hi all,
I have a data set with time interval and depending on the interval I want
to create 5 more variables . Sample data below
obs, Start, End
1,2/1/2015, 1/1/2017
2,4/11/2010, 1/1/2011
3,1/4/2006, 5/3/2007
4,10/1/2007, 1/1/2008
5,6/1/2011, 1/1/2012
6,10/15/2004,12/1/2004
First, I want get interval between the start date and end dates
(End-start).
obs, Start , end, datediff
2017 Jun 03
0
New var
Ii is difficult to provide useful help, because you have failed to
read and follow the posting guide. In particular:
1. Plain text, not HTML.
2. Use dput() or provide code to create your example. Text printouts
such as that which you gave require some work to wrangle into into an
example that we can test.
Specifically:
3. Have you gone through any R tutorials?-- it sure doesn't look like
2017 Jun 03
2
New var
Thank you all for the useful suggestion. I did some of my homework.
library(data.table)
DFM <- read.table(header=TRUE, text='obs start end
1 2/1/2015 1/1/2017
2 4/11/2010 1/1/2011
3 1/4/2006 5/3/2007
4 10/1/2007 1/1/2008
5 6/1/2011 1/1/2012
6 10/5/2004 12/1/2004',stringsAsFactors = FALSE)
DFM
DFM$D =as.numeric(difftime(as.Date(DFM$end,format="%m/%d/%Y"),
2017 Jun 04
0
New var
# read.table is NOT part of the data.table package
#library(data.table)
DFM <- read.table( text=
'obs start end
1 2/1/2015 1/1/2017
2 4/11/2010 1/1/2011
3 1/4/2006 5/3/2007
4 10/1/2007 1/1/2008
5 6/1/2011 1/1/2012
6 10/5/2004 12/1/2004
',header = TRUE, stringsAsFactors = FALSE)
# cleaner way to compute D
DFM$start <- as.Date( DFM$start, format="%m/%d/%Y" )
DFM$end
2017 Jun 04
2
New var
Thank you Jeff and All,
Within a given time period (say 700 days, from the start day), I am
expecting measurements taken at each time interval;. In this case "0" means
measurement taken, "1" not taken (stopped or opted out and " -1" don't
consider that time period for that individual. This will be compared with
the actual measurements taken (Observed-
2017 Jun 04
0
New var
Since the number of choices is small (6), how about this?
Starting with Jeff's initial DFM:
DFM <- structure(list(obs = 1:6, start = structure(c(16467, 14710, 13152,
13787, 15126, 12696), class = "Date"), end = structure(c(17167,
14975, 13636, 13879, 15340, 12753), class = "Date"), D = c(700,
265, 484, 92, 214, 57), bin = structure(c(6L, 3L, 5L, 1L, 3L,
1L), .Label
2011 Mar 21
3
Computing row differences in new columns
Hi
I have the following columns with dates and results, sorted by subject and date. I'd like to compute the differences in dates and results for each patient, based on the previous row. Obviously the last entry for each subject should be a NA.
Which would be the best way to accomplished that ?
I guess questions like that have been already answered a thousand times, so I apologize for
2013 Jun 15
0
Calculate days with R
Hi,
May be this helps:
dat1<- read.table(text="
pbnr??????? dat? dep? dys? sop? ago? mis age female
1 10023 1994-02-21 0.75 1.00 0.50 0.50 0.75? 35????? 1
2 10023 1994-05-25 0.75 1.00 0.50 0.50 0.75? 35????? 1
3 10028 1994-02-01 2.00 1.75 3.00 0.50 1.50? 42????? 1
4 10028 1999-01-15 1.25 0.75 2.25 0.50 0.25? 42????? 1
5 10053 1994-03-16 2.50 0.75 1.25 0.50 1.25? 22????? 1
6 10053
2005 Oct 28
4
find_by_sql column types
Hello--
There must be a better way to do this. I have a class method in my model
that finds averages and does a few calculations using find_by_sql. The
problem I¹m encountering is that all computed columns from MySQL come back
as type string. E.g.,
def self.find_averages(domain_id)
if @@domain_average
return @@domain_average
else
@@domain_average =
2009 Sep 02
4
diff of two timestamps
Hi all,
I have the following problem: I have a csv-file consisting of timestamp
values (no dates), e.g.:
Timestamp1;Timestamp2;
05:24:43;05:25:05;
15:47:02;15:47:22;
18:36:05;18:36:24;
15:21:24;15:22:04;
I need a vector with the difference of the two timestamps, so I read the
data with the read.csv-function:
myObj <- read.csv("file.csv",header=TRUE,sep=";").
I have then
2010 Jul 21
0
One problem with RMySQL and a query that returns an empty recordset
My last query related to this referred to a problem with not being able to
store data. A suggestion was made to try to convert the data returned by
fitdist into a data.frame before using rbind. That failed, but provided the
key to solving the problem (which was to create a data.frame using the
variables fitdist produces in the object it returns).
I now have almost everything working as
2010 Jul 16
1
I need help making a data.fame comprised of selected columns of an original data frame.
I must have missed something simple, but still, i don't know what.
I obtained my basic data as follows:
x <- sprintf("SELECT m_id,sale_date,YEAR(sale_date) AS
sale_year,WEEK(sale_date) AS sale_week,return_type,0.0001 +
DATEDIFF(return_date,sale_date) AS elapsed_time FROM
`merchants2`.`risk_input` WHERE DATEDIFF(return_date,sale_date) IS NOT
NULL")
moreinfo <- dbGetQuery(con,
2010 Jul 08
1
Query about using timestamps returned by SQL as 'factor' for split
I have a simple query as follows:
"SELECT
m_id,sale_date,YEAR(sale_date),WEEK(sale_date),return_type,DATEDIFF(return_date,sale_date)
AS elapsed_time FROM risk_input"
I can get, and view, all the data that that query returns. The question is,
sale_date is a timestamp, and I need to call split to group this data by
m_id and the week in which the sale occurred. Obviously, I would
2007 Jul 10
0
Plot dies with memory not mapped (segfault) (PR#9785)
Full_Name: Clay B
Version: 2.5.0 (2007-04-23)
OS: Solaris Nevada Build 55b
Submission from: (NULL) (65.101.229.198)
I find that running this script causes R to segfault reliably. However, running
just for one system at a time (modifying the for loop updating iter to run just
for a system at a time works). The system is a Sun W2100z with 12 GB of ram, and
R segfaults using only around 360 MB of
2010 May 14
2
operations between two aggregated data frames?
Hi All,
I've come up with a solution for this problem that relies on a for loop,
and I was wondering if anybody had any insight into a more elegant method:
I have two data frames, each has a column for categorical data and a column
for date. What I'd like to do, ideally, is calculate the number of days
between all pairs of dates in data frame 1 and data frame 2 (*but only for
members
2008 Mar 06
1
AEL - SQL and TIMEDIFF()
Hello list,
I'm having some problem integrating the SELECT TIMEDIFF() and SELECT
DATEDIFF() in my code. The syntax I'm using works without any problems if I
run them directly from the MySQL Client, but from the Asterisk Dialplan it
just wont work. Is there a limitation in the MySQL() application for the
Asterisk dialplan that produces this error?
<CODE>
context testsql {
s =>
2006 Jan 22
23
calculate users age
i know it''s probably really simple, how do i work out someone''s age if i
have their d.o.b. stored as a date in my db.
cheers
--
Posted via http://www.ruby-forum.com/.