[R] where is "average shifted histogram"?

Martin Maechler maechler at stat.math.ethz.ch
Thu Jul 29 09:32:17 CEST 2004


>>>>> "PD" == Peter Dalgaard <p.dalgaard at biostat.ku.dk>
>>>>>     on 29 Jul 2004 08:02:54 +0200 writes:

    PD> Eckart Bindewald <eckart_bindewald at yahoo.de> writes:
    >> Hello!  In the book Modern Applied Statistics with S (4th
    >> ed), section 5.6 the concept of the "average shifted
    >> histogram" or ASH is mentionend. Also it is mentioned in
    >> the same section "The code used is in the scripts for
    >> this chapter" (from figure caption 5.8, analysis of the
    >> geyser duration data).  *However*, I have trouble finding
    >> the code for that function! Admittedly, I am a newby to
    >> R. Where exactly do I find the scripts to that chapter?
    >> Commands like library(MASS), or help.search("average
    >> shifted histogram") did not help.

    PD> The scripts are in simple files installed with the
    PD> package. So you need to go to the install directory and
    PD> read them from there. A canonical way of finding it from
    PD> within R is

    PD> .path.package("MASS")

which requires that "MASS" has been attached {as by library()}.

    PD> dir(file.path(.path.package("MASS"),scripts))
    PD> file.show(file.path(.path.package("MASS"),"scripts","ch05.R"))

eehm, as the "." in ".path.package()" suggests, there should be
a more canonical way --- and there is, using system.file() :

 dir(system.file("scripts", package = "MASS"))

 ## [1] "ch01.R" "ch02.R" "ch03.R" "ch04.R" "ch05.R" "ch06.R" "ch07.R" "ch08.R"
 ## [9] "ch09.R" "ch10.R" "ch11.R" "ch12.R" "ch13.R" "ch14.R" "ch15.R" "ch16.R"
 ##[17] "README"

 file.show(system.file(file.path("scripts","ch05.R"), package = "MASS"))


--
Martin




More information about the R-help mailing list