Displaying 20 results from an estimated 10000 matches similar to: "Calculating difference in variable values (e.g. elapsed time) in data frame"
2010 Oct 21
2
Calculating variances in a moving window
I am trying to create basic descriptive statistics for a spatial dataset
using moving windows of variable sizes.
I found the filter(dataset, rep(1/a,1)) very useful for obtaining
averages for a given moving window size "a"
(a is the window size within a column of data in a matrix - the filter
is applied to all columns automatically)
I could not find anything analogous for
2008 May 28
4
Help on Calculating day differences
Hello R Freaks,
I calculate the difference in days between two events with the following
litte R expresseion:
T1a <- strptime(T1,"%m/%d/%y %H:%M:%S");
T2a <- strptime(T2,"%m/%d/%y %H:%M:%S");
T1b <- as.Date(T1a);
T2b <- as.Date(T2a);
days <- T2b-T1b;
time <- T2a - T1a;
In the project I would like to calculate only working day.
I the a possibility to count
2013 Aug 16
1
as.Date.character speed improvement suggestion
R-Devel,
I store and retrieve a large amount of financial data (millions of rows) in a PostgreSQL database keyed by date (and represented in R by class Date). Unfortunately, I frequently find that a great deal of processing time is spent converting dates from character representations to Date class representations in R, presumably because strptime is not fast for large vectors (>10,000
2010 Mar 19
2
strptime(): on Linux system it seems to call system time?
[I am herewith re-posting this message on R-devel, as it seems to be the
most appropriate mailing list for this issue.]
Dear List,
>From what I understand, strptime() simply converts from one class
representation to another; i.e., from character to POSIXct/POSIXlt.
One strange feature of this command running on Linux is that there are
repeated calls to system time (as was revealed
2012 Sep 27
3
Calculating number of elapsed days from starting date
Hi
I have data for events in rows, with columns for person and date. Each
person may have more than one event;
tC <- textConnection("
Person date
bob 1/1/00
bob 1/2/00
bob 1/3/00
dave 1/7/00
dave 1/8/00
dave 1/10/00
kevin 1/2/00
kevin 1/3/00
kevin 1/4/00
")
data <- read.table(header=TRUE, tC)
close.connection(tC)
rm(tC)
I would like to add a new column to my dataframe containing
2012 Jul 27
1
How to run regressions over increasing time series
Hello,
I would like to run a series of regressions on my data (response variable
over time):
1) regression from T1 to T2
2) regressions from T1 through T3
3) regression from T1 through T4, etc.
I have been struggling to find a way to do this through commands, as
opposed to cutting up the data manually (my dataset has over 6000
rows/observations).
An illustrative dataset can be created thusly:
2002 Apr 08
1
Problem(?) in strptime()
I think the following examples illustrate the crux of the matter
(version and OS info are below).
The problem has to do with the transition from standard time to
daylight savings time. My timezone, US/Pacific, has two parts:
standard time (PST) 8 hours behind GMT and daylight savings time
(PDT) 7 hours behind GMT. The transition takes place this year on 7
April at 02:00, when 02:00 is
2008 May 30
3
Strptime
Hi
This code should explain what I'm trying to do
> strptime("30-Jan-08", "%d-%b-%y")
[1] "2008-01-30"
>
> format(strptime("30-Jan-08", "%d-%b-%y") , "%b-%y")
[1] "Jan-08"
>
> strptime(format(strptime("30-Jan-08", "%d-%b-%y") , "%b-%y") ,
"%b-%y")
[1] NA
I have a
2007 Jan 08
1
Does strptime(...,tz="GMT") do anything?
Hi All
In trying to correlate some tide gauge data I need to deal with varying
timezones. From the documentation on strptime, it seemed that the tz
variable might have some effect on the conversion, but I'm not seeing an
effect.
> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="PST")+0
[1] "2006-12-01 01:02:00 EST"
>
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
2007 Jun 12
1
Can strptime handle milliseconds or AM/PM?
I'm trying to proess date/time fields from files that were given to me to
analyze.
Any clues what I'm doing wrong with strptime? This seems to fail the same
way under Linux or Windows.
For ?strptime would it make sense to explain %OS3 somewhere besides the
Examples?
> # Why does %OS3 work here?
> format(Sys.time(), "%H:%M:%S")
[1] "16:45:19"
>
2020 Oct 31
2
strptime() keeps emitting warnings after establishing a handler with tryCatch()
Dear list members,
I have come about a peculiar behavior in R (4.0.2) which I would
describe as a bug.
On macOS, where `strptime()` raises a warning for invalid timezone
identifiers, the following code will continue to raise the original
warning with every subsequent call to `strptime()`:
```
# attach a handler for warnings for this call only:
tryCatch(strptime('2020-10-31 18:30', format
2020 Nov 01
0
strptime() keeps emitting warnings after establishing a handler with tryCatch()
Hello,
I cannot reproduce this behavior and, as documented, the posted code
doesn't issue warnings due to a wrong timezone but I'm running
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK:
2002 Jun 27
1
lattice and dates (correcting e-mail formatting glitch - sorry!!)
Hi
I'm fairly new to R and the list, so please take
what I say accordingly!
Far as I can see, strptime gives you a string in some
specified format. In order to do any kind of
numerically-based modelling with that, you need to
obtain a number to work with. One way to do this is by
getting the time with Sys.time() instead and coercing
it to a number using as.integer():
>
2011 Jul 06
1
trouble parsing a date using strptime()
Hi,
I am having a trouble parsing dates using strptime() that I get in the
format of year and week number. The data looks like this "201127" which
means year 2011 and week 27. I would like to graph this using ggplot but
then I get a gap between 201054 and 201101 so I thought I would just easily
convert it.
I tried to use strptime and as.Date and the format string of %Y%W but it
seems
2017 Jan 17
1
strptime("1","%m") returns NA
Hi Frederik,
On Mon, 2017-01-16 at 18:20 -0800, frederik at ofb.net wrote:
> Hi R Devel,
>
> I wrote some code which depends on 'strptime' being able to parse an
> incomplete date, like this:
>
> >
> > base::strptime("2016","%Y")
> [1] "2016-01-14 PST"
>
> The above works - although it's odd that it gives the month
2012 Jul 10
1
calculating the difference between days?
Hi List,
I have one column of beginning dates and one column of ending dates, I want
to find their difference. And I want to ignore the trailing zeros,
basically everything after the first colon mark.
Begin_date End_date
01JAN2000:00:00:00:000 02FEB2002:00:00:00:000
24MAR2012:00:00:00:000 18MAY2012:00:00:00:000
01OCT2003:00:00:00:000
2010 Apr 22
2
time difference
Hi,
Does anyone know how to take a time difference when the format of the time
is as 13:22:23.586? I am trying to take the difference of time between stock
transactions and need to keep the three decimal places for seconds. I have
tried *diff(strptime(x, "%H:%M:%S.000))*, but apperantly that doesn't work.
Carol Gao
[[alternative HTML version deleted]]
2004 Jun 17
2
Date Calculation
Hi,
I've been playing with:
> joinDate <- format(strptime(as.vector(forum[,2]), "%d-%b-%y"),
+ "%d-%b-%Y")
> today <- format(strptime(as.vector("14-Jun-04"), "%d-%b-%Y"),
+ "%d-%b-%Y")
> joinDate
[1] "04-Feb-2004" "13-Feb-2004" "26-Feb-2004"
2016 Feb 04
3
Fwd: [musl] strptime() question
There is incompatibility between R strptime and musl libc. I posted
about it on their mailing list, but they need more information I can't
provide, so I'm forwarding the message here in hope R developers can
help. Thanks.
---------- Forwarded message ----------
From: Rich Felker <dalias at libc.org>
Date: Thu, Feb 4, 2016 at 2:07 PM
Subject: Re: [musl] strptime() question
To: Alba