This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Creating R Dataset

Hi all,

I want to create dataset in R so that i load into R session as follows

data(mydatasetname)

I tried following

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

but wen i type following command to load data

data(values)

Warning message: In data(values) : data set ‘values’ not found

Can anybody help

Nitin

r

Sukhdeep has the right answer, data() is really for getting datasets from packages or the standard library in R. Just so you know, if you do create a package then plain text tables are one of of the formats that you can use in the /data directory (as per the documentation) - i.e. there is no reason to save your data in the binary format

How is this relevant to bioinformatics? This question is more suitable for StackOverflow.

1 answer

You read a table in a variable named values

values<- read.table("mydatasetname.txt")

you saved a image as an .rda (Rdata) file

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

To load it , use the load command as load('value.rda')

This will load the image you saved capturing the table you read. To confirm, type ls() which will list the values variable and typing it will output the values stored in it. Also, the data command is to load the data provided by default with the packages, so if you write data(), it will give you a list existing datasets.

HTH

Cheers

Log in to answer this question.