Create R dataset

I want to create a dataset in R to load into an R session as follows:

data(mydatasetname)

I tried the following:

values<- read.table("mydatasetname.txt") 
save(values,file="value.rda")

but when I type the following command to load data:

data(values)

Warning message: In data(values) : data setvaluesnot found

Does anyone help?

Nitin

+3
source share
2 answers

I suspect that loadmay be what you need, although I'm not sure. If you download data directly, there is no need to make a call for the data, as in:

mtcars2 <- mtcars                             #rename mtcars to mtcars2
save(mtcars2, file="mtcars2.rda")             #save mtcars2 
rm(mtcars2)                                   #remove from envir
mtcars2                                       #gone : (
load("mtcars2.rda")                           #load mtcars2 
mtcars2                                       #and you're back : )

Now you need to use load(mtcars2.rda)from now on, and your data is there.

If you want to use data(), you may need to create a package with your data and download the package, and then use the data, although I'm not 100% sure about this.

+4
source

, , , :

save(values,file="data/value.rda")

:

rm(values)

ls(), , .

, :

data(value)

. " ()", .

, : (), (), , , .

+1

All Articles