Happy New year John!
Is the following what you are looking for: y <- rnorm(40) breaks <- c(-Inf, -1, 1, Inf) x <- cut(y, breaks=breaks) plot(unclass(x), y, xaxt="n", xlab="") leftlab <- expression("(-" * infinity * "]") rightlab<- expression("[+" * infinity * ")") axlab <- levels(x) axlab[1] <- leftlab axlab[length(axlab)] <- rightlab axis(1, at=1:3, labels=axlab, line=2.25, lty=0) Cheers, Bert Gunter Genentech -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Maindonald Sent: Sunday, December 30, 2007 3:45 PM To: [EMAIL PROTECTED] Subject: [R] Symbolic substitution in parallel; use infinity symbol? I'd like to be able to modify axlab in (C) below so that 'Inf' is replaced by the infinity symbol. y <- rnorm(40) breaks <- c(-Inf, -1, 1, Inf) x <- cut(y, breaks=breaks) plot(unclass(x), y, xaxt="n", xlab="") ## A: The following gives the axis labels "(-Inf, 1]", etc. axis(1, at=1:3, labels=expression("(-Inf,-1]", "(-1,1]", "(1, Inf]")) ## B: The following replaces Inf by the infinity symbol axis(1, at=1:3, labels=expression("(" * -infinity * ", " * -1 * "]", "(" * -1 * ", 1]", "(1, " * infinity * "]"), line=1.25, lty=0) ## C: The following gives the axis labels "(-Inf, 1]", etc., ## in a more automated manner. axlab <- lapply(levels(x), function(x)substitute(a, list(a=x))) # Can alternatively use bquote() axis(1, at=1:3, labels=as.expression(axlab), line=2.25, lty=0) However I have been unable to modify axlab so that the infinity symbol appears in place of 'Inf'. Is there is some relatively straightforward way to do this? The issue is of course more general than this specific example. John Maindonald email: [EMAIL PROTECTED] phone : +61 2 (6125)3473 fax : +61 2(6125)5549 Centre for Mathematics & Its Applications, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. ______________________________________________ R-help@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. [[alternative HTML version deleted]] ______________________________________________ R-help@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.