2008/2/4, MAB <MichelBeck@sbcglobal.net>:
>
> C_Dates C_Price C_Prices_edit         C_Return_Raw        C_Return_edit
> 1   30405   29.40         29.40                 #N/A                 #N/A
> 2   30406   29.29         NaN                 -0.003               -0.003
> 3   30407      NA         29.29                    0                    0


[snip]

I attempt to convert to numeric using as.matrix (or data.matrix),
> but this converts the object to all characters.
> I can then use as.numeric to get a vector and rebuild the matrix but this
> gets
> tedious.
> Eventually the easiest seems to be to make sure each column in the
> spreadsheet
> starts with a numeric, and replace it once the object is in R.
>
> There is probably a better way.


Use the colClasses argument:

> library( "xlsReadWrite" )
> ?read.xls
>
> x <- read.xls( "TestBeck.xls", colClasses = "numeric" )
> x
  C_Dates C_Price C_Prices_edit C_Return_Raw C_Return_edit
1   30405   29.40         29.40          NaN           NaN
2   30406   29.29         29.40       -0.003        -0.003
3   30407   29.29         29.29        0.000         0.000
>
> y <- read.xls( "TestBeck.xls", colClasses = c( "isodate", rep( "numeric",
4 ) ) )
> y
     C_Dates C_Price C_Prices_edit C_Return_Raw C_Return_edit
1 1983-03-30   29.40         29.40          NaN           NaN
2 1983-03-31   29.29         29.40       -0.003        -0.003
3 1983-04-01   29.29         29.29        0.000         0.000
>

I don't understand the NA and NaN (formulas work in my example). Maybe you
could send me your Excel sheet example such that I can have a look? Thanks.

-- 
Regards,
Hans-Peter
(gchappi@gmail.com)

	[[alternative HTML version deleted]]

