[R] Wikibooks

Alberto Monteiro albmont at centroin.com.br
Fri Mar 30 15:16:05 CEST 2007


Romain Francois wrote:
>
>> Say I don't know (and I can't understand the help) how to
>> use the rnorm function. If I do RSiteSearch("rnorm"), I
>> will get too much useless information. OTOH, an ideal wikipedia
>> would have a page http://www.r-wiki.org/rnorm, where I could
>> find examples, learn the theory, browse the source code, and 
>> have links to similar functions. OK, maybe that's too much, I
>> would be happy just to have some examples :-)
> 
> Do you mean something like (it fullfills basically all your 
> requirements) :
> 
> R> rnorm     # get the code
> R> ?rnorm   # get the help page
>
This works when there's a decent documentation for the function.
The functions in the tcltk package, for example, are horribly
undocumented, and asking for help only loops to a general
help about all (and none) of the functions.
 
> The wiki already has a similar thing, for example for rnorm, you can 
> go to: http://wiki.r-project.org/rwiki/doku.php?id=rdoc:stats:Normal
> 
I didn't like the way it worked. I searched for rnorm and Norm,
and I got a list of pages. Even for this trivial example, I
have no idea how I could find anything using the Search.

> There has been (recently and less recently) some discussions on the
> r-sig-wiki list about why sometimes you get ~~RDOC~~ instead of the
> documentation page, it is still a work in progress.
> 
> The only tricky bit is how do I know that I have to go to 
> stats:normal, well you can ask that to R, for example using that 
> small function :
> 
> wikiHelp <- function( ... , sarcasm = TRUE ){
>     if(  length(hp <- help(...) ) > 0 ){
>       hp <- tail( strsplit(hp[1], "/")[[1]], 3 )
>       wikiPage <-
> sprintf("http://wiki.r-project.org/rwiki/doku.php?id=rdoc:%s:%s",
> hp[1],  hp[3])
>        cat("the following wiki page will be displayed in your 
> browser:",             wikiPage,             ">>>     Please feel 
> free to add information if you have some, " , sep = "\n")      if( 
> sarcasm) cat( ">>>     except if you are an evil person\n")      
>  browseURL(wikiPage)    } else print( hp )  }
> 
Nice code :-)

R> wikiHelp( rnorm )

~~RDOC~~ # what is this?

R> wikiHelp( tkWidgets )

No documentation for 'tkWidgets' in specified packages and libraries:
you could try 'help.search("tkWidgets")'

R> wikiHelp( seq )

Here it worked as expected.

> 
> The wiki has its own search engine already, so you can go there
> and use it. I guess you can search for "search" there and get
> info on how to search.
>
:-)))))))))))))))))))))

Or I could ask help(help) to learn how help works :-P

Alberto Monteiro



More information about the R-help mailing list