[R] converting code into a function - seperating a data frame with n columns into n individual vectors
r user
ruser2006 at yahoo.com
Fri May 5 02:16:44 CEST 2006
I have many very large dataframes with 20 columns
each.
In order to conserve memory, I wish to separate the
data frame into 20 vectors, each named the name of the
dataframe followed by .1,.2,.3
.20.
(For example purposes, one data frame is named
testa.)
e.g. testa.1, testa.2, testa.3
I have written the code to do this (see below). I am
trying to convert this into a function that I can
reuse. Suggestions are appreciated.
(I am not sure if this is the best way to approach the
problem, but I do think it will work. FYI, I really do
need all the data, so selecting subset of the data is
not a good option.)
Here is the code Ive been using:
load('c:/testa.r')
testa.1<-testa[ , 1]
testa.2<-testa[ , 2]
testa.3<-testa[ , 3]
testa.4<-testa[ , 4]
testa.5<-testa[ , 5]
testa.6<-testa[ , 6]
testa.7<-testa[ , 7]
testa.8<-testa[ , 8]
testa.9<-testa[ , 9]
testa.10<-testa[ , 10]
testa.11<-testa[ , 11]
testa.12<-testa[ , 12]
testa.13<-testa[ , 13]
testa.14<-testa[ , 14]
testa.15<-testa[ , 15]
testa.16<-testa[ , 16]
testa.17<-testa[ , 17]
testa.18<-testa[ , 18]
testa.19<-testa[ , 19]
testa.20<-testa[ , 20]
rm(testa)
gc()
More information about the R-help
mailing list