[R] Import Data from Excel

David Winsemius dwinsemius at comcast.net
Thu Aug 16 01:34:50 CEST 2012


On Aug 15, 2012, at 4:07 PM, David Winsemius wrote:

>
> On Aug 15, 2012, at 2:04 PM, li li wrote:
>
>> Dear all,
>>  I want to import just part of an excel data file into R.
>>  I would like to have the data imported without
>> rownames or colume names.
>> I used read.delim("clipboard", header=F).  Somehow even though
>> I added the argument "header=F", I still have the row names V1,  
>> V2, ...,
>> Does anyone know how to fix this?
>>  Thanks very much in advance.
>
> You could use readLines() or you could use scan().
>
> Perhaps:
>
> input <- scan(file="clipboard", what="numeric")
>
> If you know the number of columns, say 10, it could be:
>
> inpmat <- matrix( scan(file="clipboard", what="numeric"), ncol=10)

Or perhaps:

inpmat <- matrix( scan(file="clipboard", what=double() , ncol=10)

Using the first version actually gives you character values, since  
"numeric" is of of type character. Different convention than most  
other reading functions.

-- 
David Winsemius, MD
Alameda, CA, USA



More information about the R-help mailing list