[R-SIG-Finance] Converting factors back to numbers in R

ровен Акьатои volchik2000 at list.ru
Tue Dec 5 15:58:27 CET 2006

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) {
   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 :(


More information about the R-SIG-Finance mailing list