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)
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
Thank you
Ram
[[alternative HTML version deleted]]
David Winsemius
2011-Mar-28 19:43 UTC
[R] problem in simple saving and loading data frames
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 foundWithout 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
Reasonably Related Threads
- Problem accessing .Rdata objects in a loop
- Best way/practice to create a new data frame from two given ones with last column computed from the two data frames?
- rbind: inconsistent behaviour with empty data frames?
- Conditional operation on multiple columns from two data frames
- Subassignments involving NAs in data frames