Skip to content

Problems with reading data by readWorksheetFromFile of XLConnect Package

6 messages · John, Anthony Damico, David Winsemius +1 more

#
Hi,

   Attached are two datasheet to be read.
   My raw data "130502temp.xlsx" contains numbers with ' symbols, and they
can't be read as numbers. Even if I copy and paste as numbers to form a new
file "130502temp_number1.xlsx", they could not be read smoothly.

   1. How can I read the datasheet as numbers?
   2. How can I treat the notation "-" as (1) "NA" or (2) zero?

   Thanks,

Miao
startRow=2, endRow= 11, startCol=2, endCol=5)
Col1  Col2   Col3   Col4

1  647,853 1,413 57,662 27,897

2  491,400 1,365 40,919 20,411

3   38,604     -  5,505    985

4      576     -     20     54

5   80,845    21 10,211  4,494

6   36,428    27  1,007  1,953

7  269,915   587 32,988 12,779

8  224,494     - 30,554  9,184

9   11,858   587      -    686

10   3,742     -     81    415
[1] "1,365"
Error in temp[2, 2] + 3 : non-numeric argument to binary operator
header=FALSE, startRow=2, endRow= 11, startCol=2, endCol=5)
[1] "1,365"
Error in temp_num[2, 2] + 3 : non-numeric argument to binary operator
[1] NA

Warning message:

NAs introduced by coercion
#
On May 2, 2013, at 11:00 PM, jpm miao wrote:

            
Perhaps (assuming this were a data.frame to be coerced:

temp <- matrix( sapply( temp , as.numeric ), dim(temp)[1]) 

But the persistence of the "-"'s is puzzling. You should (as always) have posted the output from dput(temp).



  Thanks,
David Winsemius
Alameda, CA, USA