On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote:> On 02/10/15 10:54, peter dalgaard wrote: > >>> On 01 Oct 2015, at 23:04 , Rolf Turner <r.turner at auckland.ac.nz> >>> wrote: >>> >>> On 02/10/15 03:45, David L Carlson wrote: >>> >>> <SNIP> >>> >>>> If you want the month names: >>>> >>>>> mnt <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun", >>>> + "July", "Aug", "Sep", "Oct", "Nov", "Dec") >>>>> dimnames(tbl)$Month <- mnt >>> >>> <SNIP> >>> >>> Unnecessary typing; there is a built-in data set "month.abb" (in >>> the "base" package) that is identical to your "mnt". >>> >>> Difficult (nearly impossible!) to find, but, if you can't quite >>> remember the name! I *knew* I'd seen it, so I persisted and >>> eventually tracked it down. >>> >>> Strangely ??month or help.search("month") yield no trace of it. >>> Pages and pages of (useless!) output but no sign of "month.abb" >>> (nor of "month.name" which gives the unabbreviated month names). >>> >>> Can anyone explain to me why "??" and help.search() are of no help >>> here? >> >> Umm, >> >> ------- Help files with alias or concept or title matching ?month? >> using fuzzy matching: >> >> >> base::Constants Built-in Constants Aliases: month.abb, >> month.name .... ------- > > Hmm. When I did ??month I got a completely different display. It > contained *absolutely no* mention of month.abb. That *seems* to be > because I have help_type set to "html". When I re-set help_type to > "text", I get a display like unto the one that you obtained (and it does indeed lead one to month.abb). > > It seems to me ver' strange that one gets a different collection of > information under help_type="text" than one does under help_type="html". > If I were me, I would classify this as a bug. > >> Also, entering "month<TAB><TAB>" gives the completions >> >>> month >> month.abb monthplot months.Date month.name months >> months.POSIXt > > Yes, I eventually managed to come up with this trick as well. But that is not really relevant to the phenomenon that "??" or help.search() don't work effectively, or at least not consistently (the effectiveness appearing to depend --- for some bizarre reason --- on the value of help_type). > > cheers, > > Rolf > > P.S. I have been unable to find a corresponding vector of the names of the days of the week, although I have a very vague recollection of the existence of such a vector. Does it exist, and if so what is it called?It's could called up by strptime because it is mapped to a character vector by the internationalization database:> format( as.Date(1:7)+2, format="%A")[1] "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" [7] "Saturday"> Or is my recollection an illusion brought on by advancing senility? > > R. > > -- > Technical Editor ANZJS > Department of Statistics > University of Auckland > Phone: +64-9-373-7599 ext. 88276 > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.David Winsemius Alameda, CA, USA
On 02/10/15 15:47, David Winsemius wrote: <SNIP>> On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote: >> >> P.S. I have been unable to find a corresponding vector of the names >> of the days of the week, although I have a very vague recollection >> of the existence of such a vector. Does it exist, and if so what >> is it called? > > It's could called up by strptime because it is mapped to a character > vector by the internationalization database: > >> format( as.Date(1:7)+2, format="%A") > [1] "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" > "Friday" [7] "Saturday"<SNIP> When I try that (copying and pasting your code so that there's no chance of fumble-fingering) I get:> Error in as.Date.numeric(1:7) : 'origin' must be suppliedWhy do these things always happen to *me*??? cheers, Rolf -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276
On Oct 1, 2015, at 8:29 PM, Rolf Turner wrote:> On 02/10/15 15:47, David Winsemius wrote: > > <SNIP> > >> On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote: >>> >>> P.S. I have been unable to find a corresponding vector of the names >>> of the days of the week, although I have a very vague recollection >>> of the existence of such a vector. Does it exist, and if so what >>> is it called? >> >> It's could called up by strptime because it is mapped to a character >> vector by the internationalization database: >> >>> format( as.Date(1:7)+2, format="%A") >> [1] "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" >> "Friday" [7] "Saturday" > > <SNIP> > > When I try that (copying and pasting your code so that there's no chance of fumble-fingering) I get: > >> Error in as.Date.numeric(1:7) : 'origin' must be supplied > > Why do these things always happen to *me*???Or why am I so lucky as to avoid the need for an origin when the help page says the call is: ## S3 method for class 'numeric' as.Date(x, origin, ...) # noting no default in the formals The code says that origin should be supplied if it is missing:> as.Date.numericfunction (x, origin, ...) { if (missing(origin)) origin <- "1970-01-01" if (identical(origin, "0000-00-00")) origin <- as.Date("0000-01-01", ...) - 1 as.Date(origin, ...) + x } -- David Winsemius Alameda, CA, USA
On 01/10/2015 11:29 PM, Rolf Turner wrote:> On 02/10/15 15:47, David Winsemius wrote: > > <SNIP> > >> On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote: >>> >>> P.S. I have been unable to find a corresponding vector of the names >>> of the days of the week, although I have a very vague recollection >>> of the existence of such a vector. Does it exist, and if so what >>> is it called? >> >> It's could called up by strptime because it is mapped to a character >> vector by the internationalization database: >> >>> format( as.Date(1:7)+2, format="%A") >> [1] "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" >> "Friday" [7] "Saturday" > > <SNIP> > > When I try that (copying and pasting your code so that there's no chance > of fumble-fingering) I get: > >> Error in as.Date.numeric(1:7) : 'origin' must be supplied > > Why do these things always happen to *me*???The zoo package replaces as.Date.numeric() with a function that assumes an origin of "1970-01-01". There may be other packages that also make a replacement like this. David appears to have one of them attached, and you don't. Duncan Murdoch