Martin Maechler
1998-Mar-19 09:34 UTC
a handy function "format.cardinal", looking for a proper name..
This is not a nice name (format is generic; cardinal is not a class) for a nice function, which I would like in several places in R code and therefore would like to become part of R (under a better name !) format.cardinal <- function(i, sep="") paste(i, c("st","nd","rd","th")[pmin(4,i)], sep=sep) # Try format.cardinal(sample(1:20)) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Philippe Lambert
1998-Mar-19 11:11 UTC
a handy function "format.cardinal", looking for a proper name..
On Thu, 19 Mar 1998, Martin Maechler wrote:> This is not a nice name (format is generic; cardinal is not a class) for a > nice function, which I would like in several places in R code and therefore > would like to become part of R (under a better name !) > > format.cardinal <- function(i, sep="") > paste(i, c("st","nd","rd","th")[pmin(4,i)], sep=sep) > > # Try > format.cardinal(sample(1:20))Isn't it a problem?> format.cardinal(22)[1] "22th" Philippe> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
(from R-core)> Btw, why can't object names contain a `@'? > > -kSpeaking of names. I've been thinking whether it would not at some point be wise to introduce namespaces into R. This would pretty obviously break a lot of S code, but it would also make it possible to avoid a lot of silly problems such as naming one's variables c, t, pt, df, rm, ... A plan that might work relatively smoothly could involve: - Separate functions from variables. We already do that to some extent ("looking for object of mode function...") [At the same time, one might get rid of everyone's favourite quirk: forgetting () and thus listing the function instead of calling it. I know: basic design, functions are just objects, etc., but really: Wouldn't it be nicer to type view(ls) the few times you actually wanted to see its contents?] - All system functions and variables are really named something like sys::c() i.e. we introduce a namespace separator ::. Functions/variables that are intended for general use can be made public, by a special call. - Assignments (interactive) to an existing public name causes a warning to be issued (or maybe an error). -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._