Re: [R] p-value from GEE why factor 2*pnorm?
Benilton Carvalho schrieb: > Well, AFAIK, the definition of a p-value is the probability of > observing something at least as extreme as the observed data. > > If you observed z, and Z follows a std-normal > > p-value = P( Z < -abs(z) ) + P( Z > abs(z) ) >= 2*P ( Z > abs(z) ) >= 2*pnorm(z, lower.tail=FALSE) > > try z=0 (you should get 1) and z=1.96 (you should get 5%) > > Hi Benilton, thank you for your explanations. I seems that the unexpected Data are a result of misunderstanding the arguments of the GEE like |corstr, family or for using the GEE itself. This is a major problem and I must look for any kind of support for the GEE. Thanks Carmen | __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] p-value from GEE why factor 2*pnorm?
Benilton Carvalho schrieb: > the recommendation was to use lower.tail=FALSE. > > b > > O but then the results are significant and this does not match the observation. The results are matching the observations if the formula is pnorm(c(1.8691945,0.5882351,2.4903091,1.9287802,2.3172983,2.2092593,2.2625959,1.6395695), lower.tail =TRUE) so I have any unknown problem anywhere :-( REgards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] p-value from GEE why factor 2*pnorm?
I got an answer for the other question (thank you) But there is another question (I am afraid this is a basic question ...) In this tread there is a hint hwo to calculate the p-vlue of an GEE: > _http://finzi.psych.upenn.edu/R/Rhelp02a/archive/74150.html_ > > Then, get the P values using a normal approximation for the > distribution of z: > > /> 2 * pnorm(abs(coef(summary(fm1))[,5]), lower.tail = FALSE) / > (Intercept) TPTLD 0. 0.04190831 1. why is the result multiplicated with 2? There is a P-value between 1 and 2 with the results below and multiplicated with 2: 2*pnorm(c(1.8691945,0.5882351,2.4903091,1.9287802,2.3172983,2.2092593,2.2625959,1.6395695), lower.tail =TRUE) Regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] pnorm how to decide lower-tail true or false
Hi to all, maybe the last question was not clear enough. I did not found any hints how to decide whether it should use lower.tail or not. As it is an extra R-feature ( written in http://finzi.psych.upenn.edu/R/Rhelp02a/archive/66250.html ) I do not find anything about it in any statistical books of me. Regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] where is the NIR dataset?
I did just the download of the pls package, but the NIR dataset is not available require(pls) [1] TRUE data(NIR) Warning message: data set 'NIR' not found in: data(NIR) is there another package with the dataset for the examples? With regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] ks.test "greater" and "less"
Prof Brian Ripley schrieb: > On Sat, 16 Dec 2006, R. Villegas wrote: > >> 2006/12/15, Carmen Meier <[EMAIL PROTECTED]>: >>> Hello r-group >>> I have a question to the ks.test. >>> I would expect different values for less and greater between data1 and >>> data2. >>> Does anybody could explain my point of misunderstanding the function? > > The help page says: > > This is a comparison of cumulative distribution > functions, and the test statistic is the maximum difference in > value, with the statistic in the '"greater"' alternative being D^+ > = max_u [ F_x(u) - F_y(u) ]. > > data1 and data2 have the same empirical CDF, so should and do give the > same value of the test statistic. > > We cannot know what you misunderstanding is, since you have not > explained your expectations. > Thank you for your answers, seems that I was abusing the R-Group for statistical question which should be posted in f.e. sci.stat.edu. .. the misunderstanding was, that I thought ks.test is different between sort order decreasing and increasing. With regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] ks.test "greater" and "less"
R. Villegas schrieb: > 2 >> >> data1<-c(8,12,43,70) >> data2<- c(70,43,12,8) >> is the same for ks.test, isn't it? >> > Yes, it's the same. Wich version of R have you?. 2.4.0 Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] ks.test "greater" and "less"
Hello r-group I have a question to the ks.test. I would expect different values for less and greater between data1 and data2. Does anybody could explain my point of misunderstanding the function? data1<-c(8,12,43,70) data2<- c(70,43,12,8) ks.test(data1,"pnorm") ks.test(data1,"pnorm",alternative ="less")#expected < 0.001 ks.test(data1,"pnorm",alternative ="greater") #expected =1 ks.test(data2,"pnorm") ks.test(data2,"pnorm",alternative ="less") #expected =1 ks.test(data2,"pnorm",alternative ="greater") #expected < 0.001 With regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] par(mfrow .. how to minimize the interspace
Is there a possibility to minimize the interspace between the graphs or better is it possible to overlap the graphs a little bit? example from ?lm: ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2,10,20, labels=c("Ctl","Trt")) weight <- c(ctl, trt) anova(lm.D9 <- lm(weight ~ group)) summary(lm.D90 <- lm(weight ~ group - 1))# omitting intercept summary(resid(lm.D9) - resid(lm.D90)) #- residuals almost identical opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) plot(lm.D9, las = 1) # Residuals, Fitted, ... par(opar) With regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] bind data.frames seperately
Hi to all, I would like to bind data1 and data2 (both are coming from an Excel sheet) but only the data rows using rbind will cause double names and value. but I need only add the data.rows and the rest of the names and values should be NA value.1=c("a","b","c","d",5:54) # building similar data frame like from excel for (i in 5:54) value.1[i] <- NA#only to simulate the NAs for the example value.2=c(1:54) for (i in 5:54) value.2[i] <- NA data1<-data.frame(names=value.1, value=value.2, data.row.1=c(1:54),data.row.2=c(1:54)) value.1=c("a","b","c","d",5:69) for (i in 5:69) value.1[i] <- NA value.2=c(1:69) for (i in 5:69) value.2[i] <- NA data2<-data.frame(names=value.1, value.2, data.row.1=c(1:69),data.row.2=c(1:69)) By the way: Why are the NAs from name are changing from NA to after the data.frame command? Thank you for your help Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] error using environment(f) <- NULL
Hi To all, I found in the tread http://finzi.psych.upenn.edu/R/Rhelp02a/archive/46740.html the reply for /> y <- 3 / /> f <- function(x) y / /> environment(f) <- NULL / /> f(1) /but this example (R 2.4.0) will cause an error: The use of the NULL environment is not longer possible (translated) The ?environment reports the NULL as possible. is there any other way now ,to get the same result Regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] writing function with ,... )
Thanks, a lot I was not able to find it the hole day ... Carmen Phil Spector schrieb: > Carmen - >You certainly can write functions that use ..., but you need > to extract the arguments that the dots represent with list(). > Here's a modified version of your function that may help explain > how this feature works. > > test <- function(x,...){ > print(x) > args = list(...) > if('y' %in% names(args))print(args$y) > if('z' %in% names(args))print(args$z) > } > >- Phil Spector > Statistical Computing Facility > Department of Statistics > UC Berkeley > [EMAIL PROTECTED] > > __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] writing function with ,... )
Hi to all I did not found the right hints for functions with the dot-dot-dot argument. Is it possible to write own functions with the tree dots and if yes what's wrong with the following example? test <- function(x, ...) { print (x) if (exists("y"))print(y) if (exists("z"))print(z) } test(4,y=2) With regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] String question
Hi to all I would to determinate whether bits is a binary code and I would to find out the which bit is set to 1 bits <-"00110110" I found to detect whether there are only numbers all.digits(bits) but is there any function to detect whether there are only 0 and 1 in the string And how could I get the f.e the third "bit" from the right hand side With regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] don't put line in plot
fernando espindola schrieb: > Hi R-user, > > I have a problem when try to run the next code: > > plot(prueba$IC, type="l") > > but plot with type="p", there not problem, I don't know what is the > problem?? Anybody can help me > normally there is no problem with type="l" maybe you should send a reproducible code With regards Carmen [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Question about error message - or is it a bug?
Hi to all ... the same code, but another question. I changed only the type='n' to type='l' and debugged the function xy.coords. with type = 'l' : there are the correct values of x and y inside the function xy.coords but the y value is filled with NA seems that the length is matching now because of the NAs with type = 'n' : there are the wrong values of x in the function xy.coords and the y value is not filled with NA So there is a length mismatch additionally to the wrong x values Maybe anybody could evaluate whether this is an error (some kind of misunderstanding) from me or a bug Regards Carmen see codes below #--- Code --- time <- c("2:25:00","2:26:00","2:27:00","2:28:00","2:29:00","2:30:00","2:31:00", "2:32:00","2:33:00","2:34:00","2:35:00","2:36:00","2:37:00","2:38:00", "2:39:00","2:40:00","2:41:00","2:42:00","2:43:00","2:44:00","2:45:00", "2:46:00","2:47:00","2:48:00","2:49:00","2:50:00","2:51:00","2:52:00", "2:53:00","2:54:00","2:55:00","2:56:00","2:57:00","2:58:00","2:59:00", "3:00:00","3:01:00","3:02:00","3:03:00","3:04:00","3:05:00","3:06:00", "3:07:00","3:08:00","3:09:00","3:10:00","3:11:00","3:12:00","3:13:00", "3:14:00") y <- c(0,10) plot(times(time), y, type='n') #-- Debugging --- debug(xy.coords) plot(times(time), y, type='l') debug: if (is.null(y)) { ylab <- xlab if (is.language(x)) { if (inherits(x, "formula") && length(x) == 3) { ylab <- deparse(x[[2]]) xlab <- deparse(x[[3]]) y <- eval(x[[2]], environment(x), parent.frame()) x <- eval(x[[3]], environment(x), parent.frame()) } else stop("invalid first argument") } else if (inherits(x, "ts")) { y <- if (is.matrix(x)) x[, 1] else x x <- stats::time(x) xlab <- "Time" } else if (is.complex(x)) { y <- Im(x) x <- Re(x) xlab <- paste("Re(", ylab, ")", sep = "") ylab <- paste("Im(", ylab, ")", sep = "") } else if (is.matrix(x) || is.data.frame(x)) { x <- data.matrix(x) if (ncol(x) == 1) { xlab <- "Index" y <- x[, 1] x <- seq_along(y) } else { colnames <- dimnames(x)[[2]] if (is.null(colnames)) { xlab <- paste(ylab, "[,1]", sep = "") ylab <- paste(ylab, "[,2]", sep = "") } else { xlab <- colnames[1] ylab <- colnames[2] } y <- x[, 2] x <- x[, 1] } } else if (is.list(x)) { xlab <- paste(ylab, "$x", sep = "") ylab <- paste(ylab, "$y", sep = "") y <- x[["y"]] x <- x[["x"]] } else { if (is.factor(x)) x <- as.numeric(x) xlab <- "Index" y <- x x <- seq_along(x) } } Browse[1]> debug: if (inherits(x, "POSIXt")) x <- as.POSIXct(x) Browse[1]> debug: if (length(x) != length(y)) { if (recycle) { if ((nx <- length(x)) < (ny <- length(y))) x <- rep(x, length.out = ny) else y <- rep(y, length.out = nx) } else stop("'x' and 'y' lengths differ") } Browse[1]> x [1] 0.1006944 0.1013889 0.1020833 0.1027778 0.1034722 0.1041667 0.1048611 0.106 0.1062500 [10] 0.1069444 0.1076389 0.108 0.1090278 0.1097222 0.1104167 0.111 0.1118056 0.1125000 [19] 0.1131944 0.1138889 0.1145833 0.1152778 0.1159722 0.117 0.1173611 0.1180556 0.1187500 [28] 0.119 0.1201389 0.1208333 0.1215278 0.122 0.1229167 0.1236111 0.1243056 0.125 [37] 0.1256944 0.1263889 0.1270833 0.128 0.1284722 0.1291667 0.1298611 0.1305556 0.1312500 [46] 0.1319444 0.1326389 0.133 0.1340278 0.1347222 attr(,"format") [1] "h:m:s" Browse[1]> y [1] 0 10 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [31] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA Browse[1]> #-- debug(xy.coords) plot(times(time), y, type='n') debug: if (length(x) != length(y)) { if (recycle) { if ((nx <- length(x)) < (ny <- length(y))) x <- rep(x, length.out = ny) else y <- rep(y, length.out = nx) } else stop("'x' and 'y' lengths differ") } Browse[1]> debug: if (recycle) { if ((nx <- length(x)) < (ny <- length(y))) x <- rep(x, length.out = ny) else y <- rep(y, length.out = nx) } else stop("'x' and 'y' lengths differ") Browse[1]> Fehler in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ > x [1] 2 1 0 0 0 1 0 0 0 3 3 3 > y [1] 0 10 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help
Re: [R] axis command and excel time format
> > > Carmen, > > Gabor has already given you the detail you ask for, but might try the > following plot to see what is going wrong: > > plot(times(tt), x, type='l') > > This does not give you the EXACT control of the axis you asked for, > but this simple plot command gives you a fairly nice result. It > illustrates that your code is failing becasue you are plotting x > against the index of x rather than plotting x against time. At least > this is what I think the misunderstanding is. > Thank you Robert, this is nearly what I need, but my problem is that I need an empty window with axes. I am able to build this with any data but not with the time axis. I need for a special issue only horizontal lines with different colors and arrows, which will be inserted from a function. Maybe you could explain me what's the difference between library(zoo) library(chron) time <- c("2:25:00","2:26:00","2:27:00","2:28:00","2:29:00","2:30:00","2:31:00", "2:32:00","2:33:00","2:34:00","2:35:00","2:36:00","2:37:00","2:38:00", "2:39:00","2:40:00","2:41:00","2:42:00","2:43:00","2:44:00","2:45:00", "2:46:00","2:47:00","2:48:00","2:49:00","2:50:00","2:51:00","2:52:00", "2:53:00","2:54:00","2:55:00","2:56:00","2:57:00","2:58:00","2:59:00", "3:00:00","3:01:00","3:02:00","3:03:00","3:04:00","3:05:00","3:06:00", "3:07:00","3:08:00","3:09:00","3:10:00","3:11:00","3:12:00","3:13:00", "3:14:00") y <- c(0,10) plot(times(time), y, type='n') - error in xy.coords(x, y, xlabel, ylabel, log) :'x' and 'y' lengths differ - the error is only with type='n' and not with type='l' and the example without errors library(zoo) library(chron) time <- c("2:25:00","2:26:00","2:27:00","2:28:00","2:29:00","2:30:00","2:31:00", "2:32:00","2:33:00","2:34:00","2:35:00","2:36:00","2:37:00","2:38:00", "2:39:00","2:40:00","2:41:00","2:42:00","2:43:00","2:44:00","2:45:00", "2:46:00","2:47:00","2:48:00","2:49:00","2:50:00","2:51:00","2:52:00", "2:53:00","2:54:00","2:55:00","2:56:00","2:57:00","2:58:00","2:59:00", "3:00:00","3:01:00","3:02:00","3:03:00","3:04:00","3:05:00","3:06:00", "3:07:00","3:08:00","3:09:00","3:10:00","3:11:00","3:12:00","3:13:00", "3:14:00") y <- c(0,10) plot(times(time), y, type='l') It is not the type='n' every other combination of data types which i tried was working with the no plot option y <- c(0,10) z <- c(0,10) plot(z, y, type='n') Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] axis command and excel time format
Gabor Grothendieck schrieb: > You are using two different x's and one has nothing to do with the other. > All of your examples are simply internally inconsistent so there is no > reason to think they would work. Sorry Gabor, I am getting more and more confused about the problem.. but I think I have found my point of mistake: range(x <- c(0,m)) #50 minutes range(y <- c(0,10)) plot(x,y, type="n",adj=0, asp=0, xlab="", ylab="",axes=FALSE,font.axis=2) axis(1, 0:m,font=2) # works fine but not with times I thought axis(1, 0:m... is nessessary for the valuse in the x- axes. But what`s the way to get the times into the range(x <- c(0,m)) code instead c(0,5) Thank you for your patience, Carmen [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] axis command and excel time format
Gabor Grothendieck schrieb: > Please provide a complete self contained example. I can't follow the > partial code below; however, its likely you are plotting one thing > and creating axes using another so there is no reason it should > come out right. You are right .. seems to be that it was too late at night ... But I tried the right code and sent the wrong one ... the problem is still there library(zoo) library(chron) time <- c("2:25:00","2:26:00","2:27:00","2:28:00","2:29:00","2:30:00","2:31:00", "2:32:00","2:33:00","2:34:00","2:35:00","2:36:00","2:37:00","2:38:00", "2:39:00","2:40:00","2:41:00","2:42:00","2:43:00","2:44:00","2:45:00", "2:46:00","2:47:00","2:48:00","2:49:00","2:50:00","2:51:00","2:52:00", "2:53:00","2:54:00","2:55:00","2:56:00","2:57:00","2:58:00","2:59:00", "3:00:00","3:01:00","3:02:00","3:03:00","3:04:00","3:05:00","3:06:00", "3:07:00","3:08:00","3:09:00","3:10:00","3:11:00","3:12:00","3:13:00", "3:14:00") min_time <- min(times(time)) max_time <- max(times(time)) duration <- max_time-min_time h <- hours(duration) # not nessesary here m <- minutes(duration) par(cex=1.2,lwd=1) range(x <- c(0,m)) #50 minutes range(y <- c(0,10)) plot(x,y, type="n",adj=0, asp=0, xlab="", ylab="",axes=FALSE,font.axis=2) #axis(1, 0:m,font=2) # works fine but not with times #-- your suggestion mn <- times(min_time) mx <- times(max_time) n <- 12 x <- times(seq(mn, mx, length = n)) x <- times(unique(sub("..$", "00", x))) axis(1, x, sub(":00$", "", x)) # works only with plot data before #-- axis(2, 0:10,font=2) box() Best regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] axis command and excel time format
Gabor Grothendieck schrieb: > Your code plots x which has nothing to do with xt. > The same result if you change xt to x: 02:25 at the origin nothing else - I do not know why #-- your suggestion mn <- times(min_time) mx <- times(max_time) n <- 12 t <- times(seq(mn, mx, length = n)) t <- times(unique(sub("..$", "00", t))) axis(1, x, sub(":00$", "", x)) # works only with plot data before Regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] axis command and excel time format
Yes this one works, but (sorry) in the OP there was a plot without data to define the range So I tried to use your working suggestion in that manner: library(zoo) library(chron) time <- c("2:25:00","2:26:00","2:27:00","2:28:00","2:29:00","2:30:00","2:31:00", "2:32:00","2:33:00","2:34:00","2:35:00","2:36:00","2:37:00","2:38:00", "2:39:00","2:40:00","2:41:00","2:42:00","2:43:00","2:44:00","2:45:00", "2:46:00","2:47:00","2:48:00","2:49:00","2:50:00","2:51:00","2:52:00", "2:53:00","2:54:00","2:55:00","2:56:00","2:57:00","2:58:00","2:59:00", "3:00:00","3:01:00","3:02:00","3:03:00","3:04:00","3:05:00","3:06:00", "3:07:00","3:08:00","3:09:00","3:10:00","3:11:00","3:12:00","3:13:00", "3:14:00") min_time <- min(times(time)) max_time <- max(times(time)) duration <- max_time-min_time h <- hours(duration) # not nessesary here m <- minutes(duration) par(cex=1.2,lwd=1) range(x <- c(0,m)) #50 minutes range(y <- c(0,10)) plot(x,y, type="n",adj=0, asp=0, xlab="", ylab="",axes=FALSE,font.axis=2) #axis(1, 0:m,font=2) # works fine but not with times #-- your suggestion mn <- times(min_time) mx <- times(max_time) n <- 5 xt <- times(seq(mn, mx, length = n)) xt <- times(unique(sub("..$", "00", xt))) axis(1, xt, sub(":00$", "", xt)) # works only with plot data before #-- axis(2, 0:10,font=2) box() Maybe you could explain the difference Best regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] axis command and excel time format
Gabor Grothendieck schrieb: > My understanding is that the main point of your post was how to get times > on the X axis. hopefully at this point its clear how to do that and > you can > come up with some algorithm to put whatever points you want on. That´s right thank you > > Here is a slight generalization although you will likely have to > generalize > it further. . this code works fine - just I was looking for > >> library(zoo) >> library(chron) >> 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) >> z <- zoo(x, times(tt)) >> Gabor Grothendieck schrieb: >> > Is the problem how to produce an axis with a given minimum tick, >> > maximum tick and given number of ticks? In that case try this >> yes but ... ;-) >> I started with an plain R gui >> >> library(zoo) >> library(chron) >> # input data >> # z is from original example >> mn <- times("23:00:00") >> mx <- times("23:55:00") >> n <- 12 >> z <-(1:50) >> xt <- times(seq(mn, mx, length = n)) >> plot(z, xaxt = "n") >> axis(1, xt, sub(":00$", "", xt)) >> >> >> The result is an X-axes with 23:00 at the left side nothing else at the >> x-axis > > Not for me. It gives ticks all along the x axis for me. I have placed > the entire self contained code above just to be sure. This one (above) does not work R.version.string [1] "R version 2.4.0 (2006-10-03)" > packageDescription("chron")$Version [1] "2.3-9" Regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] axis command and excel time format
Gabor Grothendieck schrieb: > Is the problem how to produce an axis with a given minimum tick, > maximum tick and given number of ticks? In that case try this yes but ... ;-) I started with an plain R gui library(zoo) library(chron) # input data # z is from original example mn <- times("23:00:00") mx <- times("23:55:00") n <- 12 z <-(1:50) xt <- times(seq(mn, mx, length = n)) plot(z, xaxt = "n") axis(1, xt, sub(":00$", "", xt)) The result is an X-axes with 23:00 at the left side nothing else at the x-axis That`s just the same problem as I got with further trials of my own and a minor problem will be sub(":00$", "", xt)) if times(seq(mn, mx, length = n)) will not result xx:yy:00 values only (f.e n=17) Regards Carmen __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] axis command and excel time format
Thank you for your reply Gabor, sure, the manually written axis works fine in any configuration. but I would prefer an "automatic" input. That means that I would like to use the datafield[1] for the minimum time and the datafield[max] (means the last one) for the maximum time. divided into x steps.The datafiled size could reach more than 7000 sec. With regards Carmen Gabor Grothendieck schrieb: > Try this: > > plot(z, xaxt = "n") > xt <- paste("23", seq(5, 50, 5), sep = ":") > axis(1, times(paste(xt, 0, sep = ":")), xt) > >> >> 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" >> __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] axis command and excel time format
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@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.