Comments (5)
(note: I'm moving the content of this comment into its own issue, because it seems related and significant, but not the issue discussed here) - 7/13/09
It seems more complicated than it initially appeared. A single duration is a 1 x 2 data frame. So c(dur, dur) returns a list of four numeric objects which we can't add and subtract as durations, while list(dur, dur) returns a list of two duration objects.
it is less obvious how to put durations into a data frame in a satisfactory manner. The best I've found is
> data.frame(cbind(c(a,a), c(a,a))) X1 X2 1 1, 1 1, 1 2 1, 1 1, 1
which doesn't print the durations correctly, but is of class "data.frame"
from lubridate.
(I deleted two comments about R crashing, because I located the error to side effects of a length.duration() I had made (and now removed)) - 7/13/09
from lubridate.
THE ISSUE HERE
To have arguments of differing lengths, the durations/POSIXts/difftimes must be stored in a list or vector or data.frame. As the default, these data structures have the class "list" (or whichever is appropriate) but not the class attributes of their individual elements: "duration" "POSIXt" or "difftime."
Hence, R does not call '+.duration' when adding lists of durations. It is unclear what R does call as base::'+.list' and base::'+.default' do not exist. Either way when a list is involved in addition, R automatically returns Error: non-numeric argument to binary operators
Do we write a '+.list' to screen for durations? I think this depends also on our decision of which data structures to store durations in and how (see related issue)
from lubridate.
Duration is just a data frame, so the natural combining operation is rbind. Have a look at the code for c.duration,+ and print.duration for the basic idea.
from lubridate.
The ops functions work for vectors of different lengths. If the different lengths are not multiples of each other it provides a warning message just as base::r does. But I wonder why R doesn't use an error message instead...
from lubridate.
Related Issues (20)
- as_datetime() HOT 1
- Problems with POSIXct in R 4.3.2 HOT 1
- 'OO' format option not recognized for parsing ISO 8601 time zone offsets
- `parse_date_time()` cannot match missing zeroes
- Inconsistent behavior of `parse_date_time()` inside `dplyr::mutate()` HOT 2
- month() and otehrs fail on objects from class 'timeDate'
- ymd_hms() function left-pads some dates that have missing "seconds" values
- round_date in 0.1 sec doesn't work correctly
- FR: int_overlaps with exclusive endpoints
- unique() always zero for periods HOT 1
- Implement Set Operations methods for Dates HOT 1
- Parsing dates with `my` seems to have a limit size
- Do we need something like `%m-%` to subtract years from leap 02/29? HOT 1
- Cannot compute `<date> + lubridate::year(1)` when `<date>` is a leap day. HOT 1
- m:s:ms time data
- `dmy()` not failing (and returning incorrect date) on wrong date format
- ceiling_date() issue when using multi units
- Fractional Seconds with conversion and rounding/truncation?
- mdy("04 July 2019") GIVES "2019-04-20" : Instead should give an error.
- data.table merge doesn't work with intervals HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lubridate.