[R] axis command and excel time format

Gabor Grothendieck
Wed, 08 Nov 2006 12:59:33 -0000

Try this:

plot(z, xaxt = "n")
xt <- paste("23", seq(5, 50, 5), sep = ":")
axis(1, times(paste(xt, 0, sep = ":")), xt)

On 11/8/06, Carmen Meier <carmei3 at web.de>
wrote:
> Hi to all,
> I have some problems to get the times-scale to the x-axis the times are
> coming from an excel sheet f. e
> [1] "0:01:00" "0:02:00" "0:03:00"
"0:04:00" "0:05:00" "0:06:00" "0:07:00"
>  [8] "0:08:00" "0:09:00" "0:10:00"
"0:11:00" "0:12:00" "0:13:00" "0:14:00"
> [15] "0:15:00" "0:16:00" "0:17:00"
"0:18:00" "0:19:00" "0:20:00" "0:21:00"
> [22] "0:22:00" "0:23:00" "0:24:00"
"0:25:00" "0:26:00" "0:27:00" "0:28:00"
> [29] "0:29:00" "0:30:00" "0:31:00"
"0:32:00" "0:33:00" "0:34:00" "0:35:00"
> [36] "0:36:00" "0:37:00" "0:38:00"
"0:39:00" "0:40:00" "0:41:00" "0:42:00"
> [43] "0:43:00" "0:44:00" "0:45:00"
"0:46:00" "0:47:00" "0:48:00" "0:49:00"
> [50] "0:50:00"
>
> I found the solution from tread
> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/71234.html
> with an very good result:
> /> ># test data /
> /> >tt <- c("23:05:02", "23:10:02",
"23:15:03", "23:20:03", "23:25:03", /
> /> >"23:30:03", "23:35:03", "23:40:03",
"23:45:04", "23:50:04",
> "23:55:03", /
> /> >"23:55:03") /
> /> >x <- c(0.575764, 0.738379, 0.567414, 0.663436, 0.599834,
0.679571, /
> /> >0.88141, 0.868848, 0.969271, 0.878968, 0.990972, 0.990972) /
> /> > /
> /> >library(zoo) /
> /> >library(chron) /
> /> >z <- zoo(x, times(tt)) /
> /> >plot(z) /
> /> > /
> but I am unable to use the axis command for that issue:
> how could I change the      axis(1, xaxp=c(0,50,5),font=2)  that I will
> get a changeable amount of x-axis entries with a time format hr:min
>
>    par(cex=1.2,lwd=1)
>    range(x <- c(0,50))
>    range(y <- c(0,10))
>    plot(x,y, type="n",adj=0, asp=0, xlab="",
> ylab="",axes=FALSE,font.axis=2)
>   axis(1, xaxp=c(0,50,5),font=2)
>    axis(2, 0:10,font=2)
>    box()
>
>
>
> Thank`s in advance
>
> Carmen
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
>