The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

YZK_R (5) [Avatar] Offline
#1
Hi.
I just downloaded R (version 2.11.1 (2010-05-31) ) on my Windows XP laptop and am starting to test it out. To my knowledge, my download was "standard" - I just followed the wizard.

On page 13 of "R in Action" there is a command vignette()

Here is what I got when I tried it:
> vignette("plot"smilie
Warning message:
vignette 'plot' *not* found
> vignette()
no vignettes found

I am not sure whether I am doing something wrong or R no longer supports this vignette command.

I also want to suggest putting a warning on the "example" command. I tested it and found that it can create variables that overwrite (without warning) existing variables with the same names. For instance, example(plot) created a variable named x that over-wrote my own previously created version of x without any warning!
> x=rnorm(50)
> example(plot)

YZK

Message was edited by:
YZK_R
robert.kabacoff (170) [Avatar] Offline
#2
Re: vignette() and example() on page 13 of "R in Action"
Dear YZK_R,

The vignette() function will only show vignettes for packages that have bee installed in your library. Additionally, not all packages have vignettes.

For example, if you have installed the package "party" and you issue the command vignette(), you should see that two vignettes are available ("MOB" and "party" ) for this package. You can then issue the command vignette("MOB") to view the first one and vignette("party") to view the second.

You are absolutely right about examples overwritting existing objects of the same name. I had not noticed that before. If you include the option local=TRUE, this will not happen.

For example

> library(doBy)
> x <- 3
> example(recodevar)

recdvr> x <- c("dec","jan","feb","mar","apr","may"smilie

recdvr> src1 <- list(c("dec","jan","feb"smilie, c("mar","apr","may"smilie)

recdvr> tgt1 <- list("winter","spring"smilie

recdvr> recodevar(x,src=src1,tgt=tgt1)
[1] "winter" "winter" "winter" "spring" "spring" "spring"
> x
[1] "dec" "jan" "feb" "mar" "apr" "may"

## now with the local=TRUE option

> x <- 3
> example(recodevar, local=TRUE)

recdvr> x <- c("dec","jan","feb","mar","apr","may"smilie

recdvr> src1 <- list(c("dec","jan","feb"smilie, c("mar","apr","may"smilie)

recdvr> tgt1 <- list("winter","spring"smilie

recdvr> recodevar(x,src=src1,tgt=tgt1)
[1] "winter" "winter" "winter" "spring" "spring" "spring"
> x
[1] 3


Hope this helps.

Rob
YZK_R (5) [Avatar] Offline
#3
Re: vignette() and example() on page 13 of "R in Action"
Dear Dr. Kabacoff,
I found a similar issue with demo(graphics). And demo() does not seem to have the local= as an argument. I think it can be potentially a problematic thing - it creates all kinds of variables in the workspace.

By the way, I see that it accesses "Edgar Anderson's Iris Data" and does something to it as part of preparing the data for plotting. Specifically, it does this: pairs(iris[1:4], main="Edgar Anderson's Iris Data", pch=21,
bg = c("red", "green3", "blue")[unclass(iris$Species)])

Does this mean that the copy of the Iris Data that I now have is different from the version of that data set that came with R when I downloaded it? Or does R keep copies of these data sets untouched somewhere even if I play around with them in the workspace?

Cheers,
YZK
robert.kabacoff (170) [Avatar] Offline
#4
Re: vignette() and example() on page 13 of "R in Action"
Dear YZK,

You are correct about demo() creating variables in the current environment. I have not found a way around this yet. If you quit R and restart it, the variables created by demo() will be gone (as long as you do not save the workspace).
In any case, the datasets (like iris) that exist in packages are unaffected by what you do on the command line. The original copies are protected against anything but uninstalling the package.

Hope this helps.

Rob