[R] Reading Numeric Data -- Trivial Question

Alex K alex.j.k at gmail.com
Fri May 20 21:22:23 CEST 2005


Hello,

   I am very new to R, and this is certainly and uber-newby question:

   I am trying to read a vector of numeric data that contains the log
of daily DJI returns and simply plot a histogram of it.

   The data I have is in a text file format, on each line a number
represents the log of the returns of one day.

   I have problems in reading this in a vector numeric format.

If I try

retr<- as.numeric(read.table("logDJI.TXT", header=FALSE, sep="", dec="." )); 

I get:
" Error in as.double.default(read.table("logDJIm.TXT", header = FALSE,
sep = "",  :
        (list) object cannot be coerced to 'double'"

and when I try to plot:

 plot(density(retr, width=.004), type="l", xlab="y", ylab="pdf");

I get:

"Error in density(retr, width = 0.004) : argument 'x' must be numeric"

  If I try:

retr<- as.data.frame(read.table("logDJI.TXT", header=FALSE, sep="", dec="." )); 

I get no reading or conversion error, but I get the same error when I
try to plot as above.

Can anyone help with this?

Thank you in advance,
Alex




More information about the R-help mailing list