Hello all, I'm using R to visualize and explore the data produced by a software system. The software generates logs for many types of events. The software runs for days on end, and can possibly generate multiple events per second. What is the appropriate time format for year, month, day, hour, minute, second, millisecond? that R can properly interpret (using zoo? or ITS?) I'll have to change the software to generate the time tags in the appropriate format. Hopefully the format will not have any spaces so I can use "cut" to separate fields. Is it best practice to put each different type of event in a different field? What is the best data structure to hold this? I've only used "tseries" data without time-tags thus far, and am new to R and don't totally understand the type of data structures possible in R (if anyone can suggest a good tutorial for that please let me know). Thanks all, B. Bogart Simon Fraser Unversity
I would suggest that you use POSIXct as the format for the date/time. This will give you resolution to almost a microsecond, so you should be able to differentiate between multiple sequencial events. As for reading it in, almost anything is reasonable; e.g., 2007/10/22 18:38:25.123456. You just have to make sure the sending system gives you the time resolution that you need. "strptime" lets you convert the character string to POSIXct. As to your data format, usually each event is a record (line of text) with the time and then event data. On 10/22/07, B. Bogart <bbogart at sfu.ca> wrote:> Hello all, > > I'm using R to visualize and explore the data produced by a software > system. The software generates logs for many types of events. The > software runs for days on end, and can possibly generate multiple events > per second. > > What is the appropriate time format for year, month, day, hour, minute, > second, millisecond? that R can properly interpret (using zoo? or ITS?) > I'll have to change the software to generate the time tags in the > appropriate format. Hopefully the format will not have any spaces so I > can use "cut" to separate fields. > > Is it best practice to put each different type of event in a different > field? What is the best data structure to hold this? I've only used > "tseries" data without time-tags thus far, and am new to R and don't > totally understand the type of data structures possible in R (if anyone > can suggest a good tutorial for that please let me know). > > Thanks all, > B. Bogart > Simon Fraser Unversity > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
R News 4/1 which gives an overview of the date time classes. On 10/22/07, B. Bogart <bbogart at sfu.ca> wrote:> Hello all, > > I'm using R to visualize and explore the data produced by a software > system. The software generates logs for many types of events. The > software runs for days on end, and can possibly generate multiple events > per second. > > What is the appropriate time format for year, month, day, hour, minute, > second, millisecond? that R can properly interpret (using zoo? or ITS?) > I'll have to change the software to generate the time tags in the > appropriate format. Hopefully the format will not have any spaces so I > can use "cut" to separate fields. > > Is it best practice to put each different type of event in a different > field? What is the best data structure to hold this? I've only used > "tseries" data without time-tags thus far, and am new to R and don't > totally understand the type of data structures possible in R (if anyone > can suggest a good tutorial for that please let me know). > > Thanks all, > B. Bogart > Simon Fraser Unversity > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
Hey all again, So I'm going through tutorials and getting a better sense of R structures. So I made some mockup data to see if I can figure out how to load it properly. (attached) if anyone has any suggestions on a better way to structure that data please let me know. So the file has three columns, the date/time of the event, the event name, the event state (if there is one) and the event value (if there is one). I'm using the built-in date/time class of openoffice as a starting point for the date/time. I'm expecting to load this file as a data.frame where each column is a different class. Like so: > data <- read.table(file="testdata.csv",sep=",",header=TRUE,colClasses=c("zoo","factor","factor","numeric")) Unfortunately It seems there is no function for converting from "character" to "zoo": Error in methods::as(data[[i]], colClasses[i]) : no method or default for coercing "character" to "zoo" So I tried using POSIXct as suggested. Which does load the file, but it seems the times are truncated, leaving only the dates: > data Time Event State Value 1 24-10-20 BMU 20 2 25-10-20 Image 2 ...3 26-10-20 BMU 10 4 27-10-20 BMU 11 5 28-10-20 Image 3 6 29-10-20 DPMS Begin NA 7 30-10-20 Dream Begin NA 8 31-10-20 BMU 3 9 1-11-20 Image 4 10 2-11-20 BMU 50 11 3-11-20 BMU 20 12 4-11-20 DPMS End NA 13 5-11-20 Dream End NA Same results as using "Date" as the colClass. Any advice? Thanks, B. Bogart