[R] Time intervals in a datframe

David Winsemius dw|n@em|u@ @end|ng |rom comc@@t@net
Tue Apr 17 23:10:43 CEST 2018


> On Apr 17, 2018, at 10:10 AM, Allaisone 1 <allaisone1 using hotmail.com> wrote:
> 
> 
> Hi all
> 
> I have a list of multiple datframes with the same column headers. The last column in each datframe contains a vector of "Interval" class after I have produced this column using "lubridate" package. I needed to convert my list of dataframes to be in a single dataframe for further analysis. I did this using the following syntax :
> 
> SingleDataframe <- ldply (MylistofDFs,data.frame)
> 
> The problem is that after this conversion, the the column with time intervals has been converted into numeric type with number of seconds during the time interval instead of the interval itself as follows :
> 
> The column Before conversion looks like this:
> 
> TimeInterval (class 'interval')
> 2012-12-13 UTC--2016-02-16 UTC
> 
> but after conversion the list into dataframe,
> This column becomes number of seconds as follows :
> 
> TimeInterval (class : numeric)
> 100224000
> 
> Is there any method to convert my list into a a single dataframe without affecting the types of
> vectors in my dataframes?. i.e. I want to keep the interval column as it with avoidance its conversion into numeric when I convert my list of dataframes into a single dataframe... Or at least keep the same format of the interval even if this has been changed to "character" type vector even though I prefer to be in "interval" class.

There is no base R class called "interval". Perhaps lubridate has not provided you with an `ldply( . ,data.frame)`-accessible method for concatenation. You should construct an example that starts with the loading code for whatever package(s) are being used.


> 
> Any suggestions would be very appreciated.
> 
> Regards
> 
> 	[[alternative HTML version deleted]]
> 

You should also read the Posting Guide.


> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   -Gehm's Corollary to Clarke's Third Law




More information about the R-help mailing list