Message-ID: <E1GrbkZ-0009Kj-00.volchik2000-list-ru@f65.mail.ru>
Date: 2006-12-05T14:58:27Z
From: Yuri Volchik
Subject: Converting factors back to numbers in R
In-Reply-To: <mailman.13.1165057204.16307.r-sig-finance@stat.math.ethz.ch>
Hi everybody,
i've spent a lot of time trying to fix the following problem:
i'm trying to load into R several dataframes with stocks data through:
dat<-lapply(1:Number.of.contracts,function(x) {
print(Names[x])
read.csv(paste(WorkingDirectory,Names[x], '_',TimeFrame,'.csv',sep=''),as.is=T,header=T,row.names=1,na.strings=c("#NA",""))
})
Because the header are times in the format "HH:MM" R converts them to strings, changing in the way. It's now a problem, i can fix it using sub (gsub) functions.
Problem is that R converts prices to factors as well even though i have option as.is=T set, and then it almost impossible to convert them back to double preserving the row.names (these are dates) and column names (times), probably because of the structure i store them in (list of dataframes).
I suspect there is an easy way to solve this problem, but couldn't figure it out :(
Thanks