[R] importing excel-file#caveat clipboard

christian.ritter at shell.com christian.ritter at shell.com
Tue Apr 24 10:00:45 CEST 2007


Just a little caveat concerning the use of the clipboard to transfer data from excel to R:

If I remember right, at least up to Excel 2003, copying data from a worksheet (Edit/Copy) to the windows clipboard, copies the data in the number format in which they are seen in Excel. That is, if you formatted your data to be easy to read (for example, you formated 12.3456 to 12.3), the 12.3 (and not the original number) will be copied to the clipboard. When you then get the data into R (via read.delim or delim2), 12.3 will be the number which will be transferred. This is a little peculiar, since if you paste what you copied into a different worksheet (instead of R) you recover all decimals ... but this uses the office clipboard ...

So, if you wish to use the clipboard trick, first remove all number formats, then copy ... 

Have a nice day,

Chris. 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Peter Dalgaard
Sent: Thursday, 19 April, 2007 2:39 PM
To: John Field
Cc: Schmitt, Corinna; r-help at stat.math.ethz.ch
Subject: Re: [R] importing excel-file


John Field wrote:
> Corinna,
>
> I find the easiest way to read simple Excel files (under Windows) is 
> to highlight the section of the worksheet I want to read, copy it to 
> the clipboard, and then use
>
> data <- read.delim("clipboard")
>
> You will also need  the parameter dec="," to set the decimal point.
>   
Or use read.delim2, which is what it is for.
> Regards,
> John Field
> Adelaide, SA
>
>
>
> Message: 23
> Date: Wed, 18 Apr 2007 16:10:51 +0200
> From: "Schmitt, Corinna" <Corinna.Schmitt at igb.fraunhofer.de>
> Subject: [R] importing excel-file
> To: <r-help at stat.math.ethz.ch>
> Message-ID:
>          <8B7B0FD99E8AF541A21609104D1961589128BD at izs-xchg01.izs.fraunhofer.de>
> Content-Type: text/plain; charset="us-ascii"
> Dear R-experts,
> It is a quite stupid question but please help me. I am very confuced. I
> am able to import normal txt ant mat-files to R but unable to import
> .xls-file
> I do not understand the online help. Can please anyone send me the
> corresponding command lines? The .xls-file is attached. In my file we
> use commas for the decimal format (example: 0,712), changes might be
> needed.
> Thanks, Corinna
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list