[R] fBasics
Flatman
flatman at swing.be
Sun Sep 12 11:45:11 CEST 2004
hello !
I'm trying to follow some examples in fBasics ...
the routine needs a 'fields' function but doesn't find it :
here's the code :
library(fBasics)
library(fSeries)
symbol="AOLA"
"ymd2cymd" <- function(x) {
# Transfor Date:
output <- is.character(x)
x <- as.integer(as.character(x))
x <- (19+cumsum(1-sign(c(1,diff(x))))/2)*1000000 + x
if(output) x <- as.character(x)
# Return result:
x }
file=paste(symbol,".csv",sep="")
query=paste("s=",symbol,"&d=7&e=22&f=2004&g=d&a=7&b=8&c=2000",sep="")
STOCK =
yahooImport(save=TRUE,file=file,source="http://ichart.yahoo.com/
table.csv?",query=query)
FULLTABLE <- matrix
(data=scan(file=file,what="",skip=1,sep=","),byrow=T,ncol=7)
PRIJZEN <- c(as.real(FULLTABLE[,2]))
namesFULLTABLE <- fields(scan(file=file,n=1,what="",sep="\n"))
^^^^^ <- here happens the
error !
FULLTABLE[,1] <-
ymd2cymd(rev(dates(FULLTABLE[,1],format="d-mon-
y",out.format="ymd",century=2000)))
FULLTABLE <- data.frame(FULLTABLE)
names(FULLTABLE) <- namesFULLTABLE
for( i in 2:length(namesFULLTABLE) ) FULLTABLE[,i] <- rev(FULLTABLE[,i])
write.table(FULLTABLE,file=file, dinnames.write="colnames")
can someone help ?
thanks in advance
More information about the R-help
mailing list