[R] Re storing a UPDATES on a data.frame

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Feb 16 11:13:44 CET 2008


Well

- MASS is a package and not a library
- it is not 'base' but 'contributed', and as library(help=MASS) says, 
support software for a book.  It is on CRAN.
- Packages with namespaces are read-only, so you have not changed the 
data frame in MASS, and even for other packages you can only change the 
copy in memory, not that on disc (all 'unless you know to subvert the 
standard ways').

What you likely did was to create a new data frame 'whiteside' in your 
user workspace and then save the workspace containing it.  In which case

rm(whiteside)
save.image()

will fix it.  However, you should have got warnings about conflicts when 
you started R, but perhaps you forgot to mention those.

Perhaps the following might be educative:

> library(MASS)
> find("whiteside")
[1] "package:MASS"
> whiteside$temp <- 1
> find("whiteside")
[1] ".GlobalEnv"   "package:MASS"

This is really an internal version of

whiteside <- `$<-`(whiteside, temp, 1)

and that assigns in the current frame just like  any other assignment.


On Fri, 15 Feb 2008, savanna3000 wrote:

>
> Hello everyone,
>
>  Can anyone tell me how do I restore data in a data.frame provided by base
> R libraries (MASS) ?
> I uninstalled R then installed it again and I still see the new changes I
> made!!!???
> (eg. whiteside$Temp=1 ==> 1 overwrote all the rows, I want the old values :(
> !!
>
>
>  Please HELP!
> --
> View this message in context: http://www.nabble.com/Restoring-a-UPDATES-on-a-data.frame-tp15512767p15512767.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list