[R] save() and load()
Shu Fai Cheung
@hu|@|@cheung @end|ng |rom gm@||@com
Tue Sep 26 03:38:46 CEST 2023
Hi,
You can try this:
head(irisdata)
Objects loaded by load() keep their names when being saved. In your
case, it is 'irisdata'.
You can also use verbose = TRUE to show the names of objects loaded:
load(file = "irisdataTest.RData", verbose = TRUE)
Hope this helps.
Regards,
Shu Fai
On Tue, Sep 26, 2023 at 9:24 AM AbouEl-Makarim Aboueissa
<abouelmakarim1962 using gmail.com> wrote:
>
> Dear ALL:
>
> I am teaching statistical packages class this semester, in R programing I
> am trying to explain the use of save() and load() with an example using the
> iris data. It seems that the save() function works, BUT when I tried to
> load the data back to R, it seems that there is a problem(s), I could not
> figure out what went wrong.
>
> Any help would be highly appreciated.
>
>
> I saved the iris data in my computer in the text format, "iris.with.head.txt
> ".
>
> Here are my R codes:
>
> > irisdata<-read.table("G:/iris.with.head.txt", header=T)
> >
> > head(irisdata)
> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
> 1 5.1 3.5 1.4 0.2 setosa
> 2 4.9 3.0 1.4 0.2 setosa
> 3 4.7 3.2 1.3 0.2 setosa
> 4 4.6 3.1 1.5 0.2 setosa
> 5 5.0 3.6 1.4 0.2 setosa
> 6 5.4 3.9 1.7 0.4 setosa
>
>
>
> *##### saving the data as an .rda*
>
> save(irisdata,file="G:/irisdataTest.rda")
>
> *##### load the data back to R*
>
> load(file="G:/irisdataTest.rda")
>
>
> >head(irisdataTest)
> Error in head(irisdataTest) : object 'irisdataTest' not found
>
> > irisdataTest
> Error: object 'irisdataTest' not found
>
>
>
> with many thanks
> abou
> ______________________
>
>
> *AbouEl-Makarim Aboueissa, PhD*
>
> *Professor, Mathematics and Statistics*
> *Graduate Coordinator*
>
> *Department of Mathematics and Statistics*
> *University of Southern Maine*
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using 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.
More information about the R-help
mailing list