Hi
    I just started using RGui.exe under widnows.
  I have a text file containing date arranged in columns and rows, each column 
has the same format, each row with different formats. 3 of the columns are 
something like this 1/12/2006 3:59:45 PM
  I need to calculate the different in seconds between 2 selected periods using 
their row’s index
   
  My solution:
  Read the file in a data frame and collect the columns in concern in a 
variable.
  data1 <- read.table("C:\\path\\data.txt", header=TRUE)
  ts <- paste(data1[[1]], data1[[3]], data1[[7]])   
   
  #ts now looks like this 
  #... "1/12/2006 3:59:45 PM"  "1/12/2006 3:59:57 PM" ...
   
  #now convert between character representations and object of classes "POSIXct"
  x <- strptime(ts, "%m/%d/%y %I:%M:%S %p")
   
  this last code line is putting out NA, what did I do wrong?
   
  After this then I do
  z <- as.POSIXct(x)
   
  Is my whole approach efficient?
  Then I can use difftime, because using it without the above preparations 
gives this
   
  > difftime(c("1/12/2006 3:59:45 PM", "1/12/2006 3:59:57 PM"), format 
="%m/%d/%y %I:%M:%S %p")
  Error in difftime(c("1/12/2006 3:59:45 PM", "1/12/2006 3:59:57 PM"), format = 
"%m/%d/%y %I:%M:%S %p") : 
          unused argument(s) (format ...)
   
  Thanks
  
__________________________________________________



        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to