[R] problem in simple saving and loading data frames

David Winsemius dwinsemius at comcast.net
Mon Mar 28 21:43:14 CEST 2011


On Mar 28, 2011, at 11:20 AM, Ram H. Sharma wrote:

> Dear all
>
> My dataframe has > 80,000 variables which I can not everytime load  
> into R
> using *.txt files (read.table option), cost me time and sometime  
> computer
> decomes not responsive. So I need a way to save my dataframe in my
> workdirectory as such.
>
> Execuse me if the problem is too simple. I tried the following, I do  
> not
> know what is wrong with it:
>
> Example data:
> x <- 1:10
> y <- 21:30
> z <- 31:40
> df2 <- data.frame(x,y, z)
> save(df2, file="df2.RData")
> My trials
>
> # trying to load
> data(df2)

The data() function load from package libraries.

> Warning message:
> In data(df2) : data set 'df2' not found
> data(df2.RData)
> Warning message:
> In data(df2.RData) : data set 'df2.RData' not found
>
> data("df2.RData")
> Warning message:
> In data("df2.RData") : data set 'df2.RData' not found
>
> load(df2)
> Error in load(df2) : bad 'file' argument
>
> load(df2.RData)
> Error in load(df2.RData) : object 'df2.RData' not found

Without quotes around df2.Rdata,  R thinks you want a file whose name  
can be found in a character vector of that name that is already in the  
workspace.

try:

load(file="df2.RData")

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list