[R] time difference error

jim holtman jholtman at gmail.com
Tue Oct 30 18:08:41 CET 2007


I think the error message says it all.  "fix" can not handle the data
type of tdiff:

> tdiff <-structure(c(168, NA, NA, 165, 175, 140, 191, 195, 130, 160, 135,
+  165, 330, 178, 141, NA, 119, 90, 70, 99, 115, 70, 65, 90, 90, 65, 90, 75,
+  85, 93, 52, 75, 60, 90, 105, 70, 65, 60, 85, 110, 65, 60, 98, 62, 71, 61, 41,
+  80, 67, 83, 72, 73),
+  tzone = "", units = "mins", class = "difftime")
> tdiff
Time differences in mins
 [1] 168  NA  NA 165 175 140 191 195 130 160 135 165 330 178 141  NA
119  90  70  99 115  70  65  90
[25]  90  65  90  75  85  93  52  75  60  90 105  70  65  60  85 110
65  60  98  62  71  61  41  80
[49]  67  83  72  73
attr(,"tzone")
[1] ""
> x <- data.frame(tdiff)
> fix(x)
Error in edit.data.frame(get(subx, envir = parent), title = subx, ...) :
  can only handle vector and factor elements
> str(x)
'data.frame':   52 obs. of  1 variable:
 $ tdiff:Class 'difftime'  atomic [1:52] 168 NA NA 165 175 140 191 195
130 160 ...
  .. ..- attr(*, "tzone")= chr ""
  .. ..- attr(*, "units")= chr "mins"
> View(x)

If you want to look at it, use "View".

On 10/30/07, Jojje Andersson <dietaamigo at hotmail.com> wrote:
> Hello!
> I posted this question earlier but it seems that something went wrong, so I post it again.
> I have a problem making a new variabel in a dataframe that consists of a time difference. It seems that the new variable gets into the dataframe but I cant look at it anymoore. Here is what happens. > tdiff<- difftime(Kontrolltid, Starttid, units="auto")
> > tdiff
>
> Time differences in mins
> [1] 168  NA  NA 165 175 140 191 195 130 160 135 165 330 178 141  NA 119  90  70
> [20]  99 115  70  65  90  90  65  90  75  85  93  52  75  60  90 105  70  65  60
> [39]  85 110  65  60  98  62  71  61  41  80  67  83  72  73
> attr(,"tzone")[1] "" > givnona<- data.frame(givnona, tdiff) names(givnona)
> [1] "Vanna"       "Datum"       "Starttid"    "Kontrolltid" "Zo.Höger"
> [6] "Zo.Vänster"  "Mm.Höger"    "Mm.Vänster"  "tot.zo"      "tot.mm"
> [11] "tdiff"
>  fix(givnona)
> Error in edit.data.frame(get(subx, envir = parent), title = subx, ...) :
> can only handle vector and factor elements   tdiff <-structure(c(168, NA, NA, 165, 175, 140, 191, 195, 130, 160, 135,
>  165, 330, 178, 141, NA, 119, 90, 70, 99, 115, 70, 65, 90, 90, 65, 90, 75,
>  85, 93, 52, 75, 60, 90, 105, 70, 65, 60, 85, 110, 65, 60, 98, 62, 71, 61, 41,
>  80, 67, 83, 72, 73),
>  tzone = "", units = "mins", class = "difftime")>  Any solution?cheers/Jojje
> _________________________________________________________________
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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?



More information about the R-help mailing list