Re: [R] Easy cut paste from Excel to R

2005-09-30 Thread stefan . albrecht
Maybe this helps, too.


readExcel - function(row.names = 1, check.names = FALSE, ...)
  read.delim(clipboard, row.names = row.names, check.names = 
check.names, ...)

writeExcel - function(x, check.rows = FALSE, check.names = FALSE, ...){
  df - data.frame(x, check.rows = check.rows, check.names = check.names)
  write.table(df, clipboard, sep = \t, col.names = NA, ...)
}


Best regards,
Stefan

---
Dr. Stefan Albrecht, CFA
Allianz Private Equity Partners GmbH
Giselastraße 4
D-80802 Munich, Germany
Phone: +49.89.38 00 - 18 317
Fax: +49.89.38 00 - 818 317
[EMAIL PROTECTED]
www.apep.com
[[alternative HTML version deleted]]

__
R-help@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

Re: [R] Easy cut paste from Excel to R?

2005-09-30 Thread roger bos
Thanks Gabor and Petr. It seems that all you have to do is use 'clipboard'
and not 'file(clipboard)' as we were doing. The row.names won't copy if
you use file. I don't know if that is a bug or a feature, but if you were
debugging someones code who already had 'file()' there, it would be hard to
figure out that that was the culprut.
 Roger

 On 9/29/05, Petr Pikal [EMAIL PROTECTED] wrote:

 Hi

 Works for me.

 write.excel - function (tab, ...) write.table(tab, clipboard, sep
 = \t, row.names = F)

 write.excel(a)

 from your example shows in Excel after ctrl-V as a table with names.

 HTH

 Petr





 On 29 Sep 2005 at 12:12, Jose Quesada wrote:

 Date sent: Thu, 29 Sep 2005 12:12:00 +0100
 From: Jose Quesada [EMAIL PROTECTED]
 To: Werner Wernersen [EMAIL PROTECTED]
 Copies to: r-help@stat.math.ethz.ch
 Subject: Re: [R] Easy cut  paste from Excel to R?
 Send reply to: Jose Quesada [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]

  Sorry to revive and old topic, but writing to the clipboard seems to
  have a problem for me: column names are ignored. Example:
 
  # ~~~
  # write.clipboard
  # ~~~
  write.clipboard = function(obj) {
  write.table(obj, file(clipboard), sep=\t, row.names=F,
  col.names=T)
  }
 
  a= matrix(1:4,2,2)
  colnames(a) = c(a, b)
 
  write.clipboard(a)
  a = as.data.frame(a)
  write.clipboard(a)
 
  both attempts will paste the date without column names.
  Any idea why?
 
  Thanks,
  -Jose
 
  On 2/16/05, Werner Wernersen [EMAIL PROTECTED] wrote:
   Thank you all very much for the answers!
   The read.table / read.delim2 commands are exactly what
   I was looking for to get
   a couple of numbers or a little matrix quickly into R
   without creating an extra
   text file every time.
  
   And it works the other way around as well:
   write.table(x, file(clipboard), sep=\t)
   Fantastic!
  
   Thanks again,
   Werner
  
   Nick Drew wrote:
I've had good luck with the scan() function when I
want to get a few numbers from Excel into R quickly
   to
use it as a calculator. CAVEAT: you have to have the
numbers you want to copy in a column not a row in
Excel. For example:
   
In Excel your data are in a column as follows:
Col A
1
2
3
   
Then copy the 3 cells (e.g. 1, 2,3) in Excel and
   open
R and type in:
   
   data - scan()
   
   
Then Paste using Ctrl-V. Hit the Enter key. You know
have an object called data that you can use and
manipulate in R.
   
I've taken this even further by creating an R
   function
that will take a column of numbers from Excel and
   then
scan() them into R, create a matrix, and then
   perform
a Chi-square test. Let me know if you'd like to know
more. I'm a beginner and if I can do so can you!!
   
~Nick
   
   
   
   
__
Do you Yahoo!?
  
  
http://promotions.yahoo.com/new_mail
   
   
  
   __
   R-help@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
  
 
 
  --
  Jose Quesada, PhD.
 
  [EMAIL PROTECTED] ESRC Postdoctoral Fellow
  http://lsa.colorado.edu/~quesadaj Dept. of PSychology
  http://www.andrew.cmu.edu/~jquesada University of Warwick
  office H114 Phone: +44 024 765 23 759
  Coventry, UK
 
  __
  R-help@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

 Petr Pikal
 [EMAIL PROTECTED]

 __
 R-help@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


[[alternative HTML version deleted]]

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-09-29 Thread Jose Quesada
Sorry to revive and old topic, but writing to the clipboard seems to
have a problem for me: column names are ignored. Example:

# ~~~
# write.clipboard
# ~~~
write.clipboard = function(obj) {
write.table(obj, file(clipboard), sep=\t, row.names=F, col.names=T)
}

a= matrix(1:4,2,2)
colnames(a) = c(a, b)

write.clipboard(a)
a = as.data.frame(a)
write.clipboard(a)

both attempts will paste the date without column names.
Any idea why?

Thanks,
-Jose

On 2/16/05, Werner Wernersen [EMAIL PROTECTED] wrote:
 Thank you all very much for the answers!
 The read.table / read.delim2 commands are exactly what
 I was looking for to get
 a couple of numbers or a little matrix quickly into R
 without creating an extra
 text file every time.

 And it works the other way around as well:
 write.table(x, file(clipboard), sep=\t)
 Fantastic!

 Thanks again,
Werner

 Nick Drew wrote:
  I've had good luck with the scan() function when I
  want to get a few numbers from Excel into R quickly
 to
  use it as a calculator. CAVEAT: you have to have the
  numbers you want to copy in a column not a row in
  Excel. For example:
 
  In Excel your data are in a column as follows:
  Col A
  1
  2
  3
 
  Then copy the 3 cells (e.g. 1, 2,3) in Excel and
 open
  R and type in:
 
 data - scan()
 
 
  Then Paste using Ctrl-V. Hit the Enter key. You know
  have an object called data that you can use and
  manipulate in R.
 
  I've taken this even further by creating an R
 function
  that will take a column of numbers from Excel and
 then
  scan() them into R, create a matrix, and then
 perform
  a Chi-square test. Let me know if you'd like to know
  more. I'm a beginner and if I can do so can you!!
 
  ~Nick
 
 
 
  
  __
  Do you Yahoo!?


  http://promotions.yahoo.com/new_mail
 
 

 __
 R-help@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



--
Jose Quesada, PhD.

[EMAIL PROTECTED]   ESRC Postdoctoral Fellow
http://lsa.colorado.edu/~quesadaj   Dept. of PSychology
http://www.andrew.cmu.edu/~jquesada University of Warwick
office H114 Phone: +44 024 765 23 
759
Coventry, UK

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-09-29 Thread Gabor Grothendieck
See:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/26922.html

On 9/29/05, Jose Quesada [EMAIL PROTECTED] wrote:
 Sorry to revive and old topic, but writing to the clipboard seems to
 have a problem for me: column names are ignored. Example:

 # ~~~
 # write.clipboard
 # ~~~
 write.clipboard = function(obj) {
write.table(obj, file(clipboard), sep=\t, row.names=F, col.names=T)
 }

 a= matrix(1:4,2,2)
 colnames(a) = c(a, b)

 write.clipboard(a)
 a = as.data.frame(a)
 write.clipboard(a)

 both attempts will paste the date without column names.
 Any idea why?

 Thanks,
 -Jose

 On 2/16/05, Werner Wernersen [EMAIL PROTECTED] wrote:
  Thank you all very much for the answers!
  The read.table / read.delim2 commands are exactly what
  I was looking for to get
  a couple of numbers or a little matrix quickly into R
  without creating an extra
  text file every time.
 
  And it works the other way around as well:
  write.table(x, file(clipboard), sep=\t)
  Fantastic!
 
  Thanks again,
 Werner
 
  Nick Drew wrote:
   I've had good luck with the scan() function when I
   want to get a few numbers from Excel into R quickly
  to
   use it as a calculator. CAVEAT: you have to have the
   numbers you want to copy in a column not a row in
   Excel. For example:
  
   In Excel your data are in a column as follows:
   Col A
   1
   2
   3
  
   Then copy the 3 cells (e.g. 1, 2,3) in Excel and
  open
   R and type in:
  
  data - scan()
  
  
   Then Paste using Ctrl-V. Hit the Enter key. You know
   have an object called data that you can use and
   manipulate in R.
  
   I've taken this even further by creating an R
  function
   that will take a column of numbers from Excel and
  then
   scan() them into R, create a matrix, and then
  perform
   a Chi-square test. Let me know if you'd like to know
   more. I'm a beginner and if I can do so can you!!
  
   ~Nick
  
  
  
  
   __
   Do you Yahoo!?
 
 
   http://promotions.yahoo.com/new_mail
  
  
 
  __
  R-help@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
 


 --
 Jose Quesada, PhD.

 [EMAIL PROTECTED] ESRC Postdoctoral Fellow
 http://lsa.colorado.edu/~quesadaj   Dept. of PSychology
 http://www.andrew.cmu.edu/~jquesada University of Warwick
 office H114 Phone: +44 024 765 23 
 759
 Coventry, UK

 __
 R-help@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


__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-09-29 Thread Petr Pikal
Hi

Works for me.

write.excel - function (tab, ...) write.table(tab, clipboard, sep 
= \t, row.names = F)

write.excel(a)

from your example shows in Excel after ctrl-V as a table with names.

HTH

Petr





On 29 Sep 2005 at 12:12, Jose Quesada wrote:

Date sent:  Thu, 29 Sep 2005 12:12:00 +0100
From:   Jose Quesada [EMAIL PROTECTED]
To: Werner Wernersen [EMAIL PROTECTED]
Copies to:  r-help@stat.math.ethz.ch
Subject:Re: [R] Easy cut  paste from Excel to R?
Send reply to:  Jose Quesada [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]

 Sorry to revive and old topic, but writing to the clipboard seems to
 have a problem for me: column names are ignored. Example:
 
 # ~~~
 # write.clipboard
 # ~~~
 write.clipboard = function(obj) {
  write.table(obj, file(clipboard), sep=\t, row.names=F,
  col.names=T)
 }
 
 a= matrix(1:4,2,2)
 colnames(a) = c(a, b)
 
 write.clipboard(a)
 a = as.data.frame(a)
 write.clipboard(a)
 
 both attempts will paste the date without column names.
 Any idea why?
 
 Thanks,
 -Jose
 
 On 2/16/05, Werner Wernersen [EMAIL PROTECTED] wrote:
  Thank you all very much for the answers!
  The read.table / read.delim2 commands are exactly what
  I was looking for to get
  a couple of numbers or a little matrix quickly into R
  without creating an extra
  text file every time.
 
  And it works the other way around as well:
  write.table(x, file(clipboard), sep=\t)
  Fantastic!
 
  Thanks again,
 Werner
 
  Nick Drew wrote:
   I've had good luck with the scan() function when I
   want to get a few numbers from Excel into R quickly
  to
   use it as a calculator. CAVEAT: you have to have the
   numbers you want to copy in a column not a row in
   Excel. For example:
  
   In Excel your data are in a column as follows:
   Col A
   1
   2
   3
  
   Then copy the 3 cells (e.g. 1, 2,3) in Excel and
  open
   R and type in:
  
  data - scan()
  
  
   Then Paste using Ctrl-V. Hit the Enter key. You know
   have an object called data that you can use and
   manipulate in R.
  
   I've taken this even further by creating an R
  function
   that will take a column of numbers from Excel and
  then
   scan() them into R, create a matrix, and then
  perform
   a Chi-square test. Let me know if you'd like to know
   more. I'm a beginner and if I can do so can you!!
  
   ~Nick
  
  
  
 
   __
   Do you Yahoo!?
 
 
   http://promotions.yahoo.com/new_mail
  
  
 
  __
  R-help@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
 
 
 
 --
 Jose Quesada, PhD.
 
 [EMAIL PROTECTED] ESRC Postdoctoral Fellow
 http://lsa.colorado.edu/~quesadaj Dept. of PSychology
 http://www.andrew.cmu.edu/~jquesada   University of Warwick
 office H114   Phone: +44 024 765 23 
 759
 Coventry, UK
 
 __
 R-help@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

Petr Pikal
[EMAIL PROTECTED]

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-23 Thread Prof Brian Ripley
On Fri, 18 Feb 2005, Peter Dalgaard wrote:
Don MacQueen [EMAIL PROTECTED] writes:
I tried Ken's suggestion
read.table(pipe(pbpaste),header=TRUE)
on my Mac OS X system and it worked *without* generating any warning message.
If my experience represents the norm, and Ken's is the exception, it
is so simple that no further contribution to R is needed, I would say.
Thank you, Ken.
My conjecture is that it only happens when there are fewer than 5 data
lines.
We still need to sort out X11. Too bad that the xclip program isn't
ubiquitous.
The read side in X11 is not too hard, and R-devel now has read from the 
primary selection via file(clipboard).  (I may change that name and 
allow reading from other selections later: I just made small changes to 
the Windows code.)

Xlib doesn't it seems really have a clipboard, and so it is much harder to 
act as the provider of the primary selection (you need to respond to X11 
events) -- xclip forks to do so.

BTW, xclip is at http://people.debian.org/~kims/xclip/ and seems no longer 
under active development (last change 18 months ago).

--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@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


X11 copy paste (was: Re: [R] Easy cut paste from Excel to R?)

2005-02-21 Thread Bernhard Bruemmer
Peter Dalgaard [EMAIL PROTECTED] writes:

 Don MacQueen [EMAIL PROTECTED] writes:

 I tried Ken's suggestion read.table(pipe(pbpaste),header=TRUE) on
 my Mac OS X system and it worked *without* generating any warning
 message.
 
 If my experience represents the norm, and Ken's is the exception, it
 is so simple that no further contribution to R is needed, I would
 say.  Thank you, Ken.

 My conjecture is that it only happens when there are fewer than 5 data
 lines.

 We still need to sort out X11. Too bad that the xclip program isn't
 ubiquitous.

Does Perl qualify as ubiquitous? If so, the piped xclip call can be
substituted for by the following:

data - read.delim(pipe(perl -MTk -e 'print MainWindow-new-SelectionGet'))

Works fine under Linux.

HTH, Bernhard

__
R-help@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


Re: X11 copy paste (was: Re: [R] Easy cut paste from Excel to R?)

2005-02-21 Thread Prof Brian Ripley
On Mon, 21 Feb 2005, Bernhard Bruemmer wrote:
Peter Dalgaard [EMAIL PROTECTED] writes:
Don MacQueen [EMAIL PROTECTED] writes:
I tried Ken's suggestion read.table(pipe(pbpaste),header=TRUE) on
my Mac OS X system and it worked *without* generating any warning
message.
If my experience represents the norm, and Ken's is the exception, it
is so simple that no further contribution to R is needed, I would
say.  Thank you, Ken.
My conjecture is that it only happens when there are fewer than 5 data
lines.
We still need to sort out X11. Too bad that the xclip program isn't
ubiquitous.
Does Perl qualify as ubiquitous?
It is specifically not required for R at runtime: see the `Writing R 
Extensions' manual.

If so, the piped xclip call can be
substituted for by the following:
data - read.delim(pipe(perl -MTk -e 'print MainWindow-new-SelectionGet'))
Works fine under Linux.
HTH, Bernhard
__
R-help@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
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-18 Thread Bernhard Bruemmer
Peter Dalgaard [EMAIL PROTECTED] writes:

 Ken Knoblauch [EMAIL PROTECTED] writes:

 Here is something quick  dirty for Mac that may be serviceable in
 some cases, while awaiting someone with greater understanding of
 programming connections than I have currently.
 
 With the following copied to the clipboard from Excell: H T Q F 1 2
 3.3 a 3 5 10.2 b 5 9 11 A
 
 I tried in R:
 
 read.table(pipe(pbpaste),header=TRUE) H T Q F 1 1 2 3.3 a 2 3 5
 10.2 b 3 5 9 11.0 A Warning message: incomplete final line found by
 readTableHeader on `pbpaste' 
 str(read.table(pipe(pbpaste),header=TRUE)) `data.frame': 3 obs. of
 4 variables: $ H: int 1 3 5 $ T: int 2 5 9 $ Q: num 3.3 10.2 11 $ F:
 Factor w/ 3 levels A,a,b: 2 3 1 Warning message: incomplete
 final line found by readTableHeader on `pbpaste'
 
 I haven't been able to track down readTableHeader yet.  The warning
 occurs even without headers in the data.

 I think the Header means the first handful of lines (up to 5) used
 to determine the file layout.

 FWIW, here's what you can do with oocalc and tcltk on Linux:

 library(tcltk)
 read.delim(textConnection(tclvalue(tcl(clipboard,get
   col1 col2 1 12 NA 2 34 56

An alternative solution for X11 is provided by the utility program xclip
(http://people.debian.org/~kims/xclip). After selecting the desired
data in, say, oocalc, the data can be
read using the appropriate read.table variant:

data - read.delim(pipe(xclip -o))

showConnections() does not reveal any problems after this command.

-- 
Dr. Bernhard Brümmer
Institute of Agricultural Economics
Georg-August-Universität Göttingen
Platz der Göttinger Sieben 5
37073 Göttingen
Germany
Tel +49 (0)551 394811 Fax +49 (0)551 399866

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-18 Thread Don MacQueen
I tried Ken's suggestion
   read.table(pipe(pbpaste),header=TRUE)
on my Mac OS X system and it worked *without* generating any warning message.
If my experience represents the norm, and Ken's is the exception, it 
is so simple that no further contribution to R is needed, I would 
say. Thank you, Ken.

The method can also be to go the other way, using pbcopy instead of pbpaste.
Emulating an example found in R's help under ?'pipe':
 test - data.frame(a=1:3,b=letters[1:3])
 zz - pipe('pbcopy','w')
 write.table(test,file=zz,sep='\t',row.names=FALSE)
 close(zz)
Then in Excel (or any other Mac-native application) use the Paste command.
In the past I would get the warning message that Ken reports when I 
used read.delim() on tab-delimited files
created using Excel's Save as tab delimited option. Excel does not 
put a newline at the
end of the last line, and as a result R would generate that error 
message.  Excel still does not.
However, R now reads such files correctly, without generating the 
warning message.

pbpaste and pbcopy are included in the OS as distributed by Apple
[163]% which pbpaste
/usr/bin/pbpaste
(though perhaps only if one of the optional developer-related 
packages has been installed)
so these methods should be available to all Mac users of R, without 
any extra work on their part
(other than learning about them, that is).

By the way, there doesn't appear to be open connection left behind:
  bah - read.table(pipe('pbpaste'),header=TRUE)
 dim(bah)
[1] 21  5
 showConnections(all=TRUE)
  description class  mode text   isopen   can read can write
0 stdin terminal r  text opened yesno
1 stdoutterminal w  text opened no yes   
2 stderrterminal w  text opened no yes   


 version
 _   
platform powerpc-apple-darwin6.8.5
arch powerpc 
os   darwin6.8.5 
system   powerpc, darwin6.8.5
status   
major2   
minor0.1 
year 2004
month11  
day  15  
language R   

Mac OS  10.3.8
Excel 2004, version 11.1 (040909)
-Don
At 11:09 PM +0100 2/17/05, Ken Knoblauch wrote:
Here is something quick  dirty for Mac that may be serviceable in
some cases, while awaiting someone with greater understanding of
programming connections than I have currently.
With the following copied to the clipboard from Excell:
H   T   Q   F
1   2   3.3 a
3   5   10.2b
5   9   11  A
I tried in R:
read.table(pipe(pbpaste),header=TRUE)
  H TQ F
1 1 2  3.3 a
2 3 5 10.2 b
3 5 9 11.0 A
Warning message:
incomplete final line found by readTableHeader on `pbpaste'
 str(read.table(pipe(pbpaste),header=TRUE))
`data.frame':   3 obs. of  4 variables:
 $ H: int  1 3 5
 $ T: int  2 5 9
 $ Q: num  3.3 10.2 11
 $ F: Factor w/ 3 levels A,a,b: 2 3 1
Warning message:
incomplete final line found by readTableHeader on `pbpaste'
I haven't been able to track down readTableHeader yet.  The warning
occurs even without headers in the data.
Quoting Prof Brian Ripley [EMAIL PROTECTED]:
 On Thu, 17 Feb 2005, Uwe Ligges wrote:
  Ken Knoblauch wrote:
 
  I tried the interesting suggestion below, discussed in several postings
  yesterday on the help-list, on my Mac (0S 10.3.7) but could not get it
 to
  work, as shown in the tests indicated below.
 
 
   read.table(file(clipboard), sep=\t, dec=,)
 
  Connections to the clipboard are only available on Windows.
 Ken is of course welcome to contribute them for MacOS X (or indeed for
 X11).
 People do take for granted the work the developers do to provide such
 things 
 --
 Brian D. Ripley,  [EMAIL PROTECTED]
  Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595


Ken Knoblauch
Inserm U 371
Cerveau et Vision
18 avenue du Doyen Lepine
69675 Bron cedex
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: 06 84 10 64 10
__
R-help@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

--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-18 Thread Peter Dalgaard
Don MacQueen [EMAIL PROTECTED] writes:

 I tried Ken's suggestion
 read.table(pipe(pbpaste),header=TRUE)
 on my Mac OS X system and it worked *without* generating any warning message.
 
 If my experience represents the norm, and Ken's is the exception, it
 is so simple that no further contribution to R is needed, I would say.
 Thank you, Ken.

My conjecture is that it only happens when there are fewer than 5 data
lines. 

We still need to sort out X11. Too bad that the xclip program isn't
ubiquitous. 

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-18 Thread Ken Knoblauch
In fact, I noticed today that when I copied from an Excell spreadsheet,
rather than just putting some text in a file, that it worked as you
say.

I also downloaded xclip and compiled it, which works just fine
on the Mac, and this mechanisms seems to work the same way as
pbpaste, in terms of generating or not warnings under the same
circumstances.  xclip has slightly different options than pbpaste
(e.g., you can access 3 different pasteboards) and it would seem to cover
the X11 situation.  So, it represents a solution that is 
slightly more general, as applying to both Mac and linux.


Quoting Don MacQueen [EMAIL PROTECTED]:

 I tried Ken's suggestion
 read.table(pipe(pbpaste),header=TRUE)
 on my Mac OS X system and it worked *without* generating any warning
 message.
 
 If my experience represents the norm, and Ken's is the exception, it 
 is so simple that no further contribution to R is needed, I would 
 say. Thank you, Ken.
 
 The method can also be to go the other way, using pbcopy instead of
 pbpaste.
 Emulating an example found in R's help under ?'pipe':
 
   test - data.frame(a=1:3,b=letters[1:3])
   zz - pipe('pbcopy','w')
   write.table(test,file=zz,sep='\t',row.names=FALSE)
   close(zz)
 
 Then in Excel (or any other Mac-native application) use the Paste command.
 
 
 In the past I would get the warning message that Ken reports when I 
 used read.delim() on tab-delimited files
 created using Excel's Save as tab delimited option. Excel does not 
 put a newline at the
 end of the last line, and as a result R would generate that error 
 message.  Excel still does not.
 However, R now reads such files correctly, without generating the 
 warning message.
 
 pbpaste and pbcopy are included in the OS as distributed by Apple
 
 [163]% which pbpaste
 /usr/bin/pbpaste
 
 (though perhaps only if one of the optional developer-related 
 packages has been installed)
 so these methods should be available to all Mac users of R, without 
 any extra work on their part
 (other than learning about them, that is).
 
 By the way, there doesn't appear to be open connection left behind:
 
bah - read.table(pipe('pbpaste'),header=TRUE)
   dim(bah)
 [1] 21  5
   showConnections(all=TRUE)
description class  mode text   isopen   can read can write
 0 stdin terminal r  text opened yesno
 1 stdoutterminal w  text opened no yes   
 2 stderrterminal w  text opened no yes   
 
 
   version
   _   
 platform powerpc-apple-darwin6.8.5
 arch powerpc 
 os   darwin6.8.5 
 system   powerpc, darwin6.8.5
 status   
 major2   
 minor0.1 
 year 2004
 month11  
 day  15  
 language R   
 
 Mac OS  10.3.8
 
 Excel 2004, version 11.1 (040909)
 
 -Don
 
 At 11:09 PM +0100 2/17/05, Ken Knoblauch wrote:
 Here is something quick  dirty for Mac that may be serviceable in
 some cases, while awaiting someone with greater understanding of
 programming connections than I have currently.
 
 With the following copied to the clipboard from Excell:
 HT   Q   F
 12   3.3 a
 35   10.2b
 59   11  A
 
 I tried in R:
 
 read.table(pipe(pbpaste),header=TRUE)
H TQ F
 1 1 2  3.3 a
 2 3 5 10.2 b
 3 5 9 11.0 A
 Warning message:
 incomplete final line found by readTableHeader on `pbpaste'
   str(read.table(pipe(pbpaste),header=TRUE))
 `data.frame':3 obs. of  4 variables:
   $ H: int  1 3 5
   $ T: int  2 5 9
   $ Q: num  3.3 10.2 11
   $ F: Factor w/ 3 levels A,a,b: 2 3 1
 Warning message:
 incomplete final line found by readTableHeader on `pbpaste'
 
 I haven't been able to track down readTableHeader yet.  The warning
 occurs even without headers in the data.
 
 
 Quoting Prof Brian Ripley [EMAIL PROTECTED]:
 
   On Thu, 17 Feb 2005, Uwe Ligges wrote:
 
Ken Knoblauch wrote:
   
I tried the interesting suggestion below, discussed in several
 postings
yesterday on the help-list, on my Mac (0S 10.3.7) but could not get
 it
   to
work, as shown in the tests indicated below.
   
   
 read.table(file(clipboard), sep=\t, dec=,)
   
Connections to the clipboard are only available on Windows.
 
   Ken is of course welcome to contribute them for MacOS X (or indeed for
   X11).
   People do take for granted the work the developers do to provide such
   things 
 
   --
   Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
   University of Oxford, Tel:  +44 1865 272861 (self)
   1 South Parks Road, +44 1865 272866 (PA)
   Oxford OX1 3TG, UKFax:  +44 1865 272595
 
 
 
 
 
 Ken Knoblauch
 Inserm U 371
 Cerveau et Vision
 18 avenue du Doyen Lepine
 69675 Bron cedex
 France
 tel: 

Re: [R] Easy cut paste from Excel to R?

2005-02-18 Thread Ken Knoblauch
You are right.  The warning disappears at exactly five lines of data,
not including the header.  

Well, how often do you come across a data.frame with less than 5 rows
and too many covariates to enter by hand?

kk


Quoting Peter Dalgaard [EMAIL PROTECTED]:

 Don MacQueen [EMAIL PROTECTED] writes:
 
  I tried Ken's suggestion
  read.table(pipe(pbpaste),header=TRUE)
  on my Mac OS X system and it worked *without* generating any warning
 message.
 
 My conjecture is that it only happens when there are fewer than 5 data
 lines. 
 
 We still need to sort out X11. Too bad that the xclip program isn't
 ubiquitous. 
 
 -- 
O__   Peter Dalgaard Blegdamsvej 3  
   c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
  (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
 




Ken Knoblauch
Inserm U 371
Cerveau et Vision
18 avenue du Doyen Lepine
69675 Bron cedex
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: 06 84 10 64 10

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-17 Thread Uwe Ligges
Ken Knoblauch wrote:
Hi,
I tried the interesting suggestion below, discussed in several postings 
yesterday on the help-list, on my Mac (0S 10.3.7) but could not get it to
work, as shown in the tests indicated below.


 read.table(file(clipboard), sep=\t, dec=,)
Connections to the clipboard are only available on Windows.
Uwe Ligges

If it is obvious (even, if not), can someone tell me what I am doing wrong?  
Do I need to perform an additional operation to open clipboard, or is this 
option not available on Mac? I did not find any special discussion of this in
the FAQ nor searching under clipboard in the archives.  Thank you, in 
advance, for any enlightenment.

data.frame(matrix(rnorm(12),ncol=3))
  X1  X2  X3
1  0.4276964 -0.49584891  0.02150469
2 -0.8323586 -0.40120649 -1.90733346
3 -0.8954563 -1.33195844 -1.28261484
4  0.4772382 -0.03703087  0.46719156
#At this point, I block-marked the printed output and apple-C'd it into the 
clipboard.
#I then checked the clipboard to verify that the data was indeed copied there.

read.table(clipboard)
Error in file(file, r) : unable to open connection
In addition: Warning message: 
cannot open file `clipboard' 

read.table(file(clipboard))
Error in open.connection(file, r) : unable to open connection
In addition: Warning message: 
cannot open file `clipboard' 

read.table(file(clipboard,r))
Error in file(clipboard, r) : unable to open connection
In addition: Warning message: 
cannot open file `clipboard' 

read.table(file(clipboard,r),header=TRUE)
Error in file(clipboard, r) : unable to open connection
In addition: Warning message: 
cannot open file `clipboard' 

read.delim(file(clipboard,r),header=TRUE)
Error in file(clipboard, r) : unable to open connection
In addition: Warning message: 
cannot open file `clipboard' 


file(clipboard)
description   classmodetext  openedcan read 
clipboard  file r  textclosed   yes 
  can write 
  yes 


file(clipboard,r)
Error in file(clipboard, r) : unable to open connection
In addition: Warning message: 
cannot open file `clipboard' 

platform powerpc-apple-darwin6.8
arch powerpc
os   darwin6.8  
system   powerpc, darwin6.8 
status  
major2  
minor0.1
year 2004   
month11 
day  15 
language R   


Ken Knoblauch
Inserm U 371
Cerveau et Vision
18 avenue du Doyen Lepine
69675 Bron cedex
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: 06 84 10 64 10
__
R-help@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
__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-17 Thread Prof Brian Ripley
On Thu, 17 Feb 2005, Uwe Ligges wrote:
Ken Knoblauch wrote:
I tried the interesting suggestion below, discussed in several postings 
yesterday on the help-list, on my Mac (0S 10.3.7) but could not get it to
work, as shown in the tests indicated below.


 read.table(file(clipboard), sep=\t, dec=,)
Connections to the clipboard are only available on Windows.
Ken is of course welcome to contribute them for MacOS X (or indeed for X11).
People do take for granted the work the developers do to provide such 
things 

--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-17 Thread Ken Knoblauch
Here is something quick  dirty for Mac that may be serviceable in
some cases, while awaiting someone with greater understanding of
programming connections than I have currently.

With the following copied to the clipboard from Excell:
H   T   Q   F
1   2   3.3 a
3   5   10.2b
5   9   11  A

I tried in R:

read.table(pipe(pbpaste),header=TRUE)
  H TQ F
1 1 2  3.3 a
2 3 5 10.2 b
3 5 9 11.0 A
Warning message: 
incomplete final line found by readTableHeader on `pbpaste' 
 str(read.table(pipe(pbpaste),header=TRUE))
`data.frame':   3 obs. of  4 variables:
 $ H: int  1 3 5
 $ T: int  2 5 9
 $ Q: num  3.3 10.2 11
 $ F: Factor w/ 3 levels A,a,b: 2 3 1
Warning message: 
incomplete final line found by readTableHeader on `pbpaste'

I haven't been able to track down readTableHeader yet.  The warning
occurs even without headers in the data. 


Quoting Prof Brian Ripley [EMAIL PROTECTED]:

 On Thu, 17 Feb 2005, Uwe Ligges wrote:
 
  Ken Knoblauch wrote:
 
  I tried the interesting suggestion below, discussed in several postings 
  yesterday on the help-list, on my Mac (0S 10.3.7) but could not get it
 to
  work, as shown in the tests indicated below.
  
  
   read.table(file(clipboard), sep=\t, dec=,)
 
  Connections to the clipboard are only available on Windows.
 
 Ken is of course welcome to contribute them for MacOS X (or indeed for
 X11).
 People do take for granted the work the developers do to provide such 
 things 
 
 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595
 




Ken Knoblauch
Inserm U 371
Cerveau et Vision
18 avenue du Doyen Lepine
69675 Bron cedex
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: 06 84 10 64 10

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-17 Thread Peter Dalgaard
Ken Knoblauch [EMAIL PROTECTED] writes:

 Here is something quick  dirty for Mac that may be serviceable in
 some cases, while awaiting someone with greater understanding of
 programming connections than I have currently.
 
 With the following copied to the clipboard from Excell:
 H T   Q   F
 1 2   3.3 a
 3 5   10.2b
 5 9   11  A
 
 I tried in R:
 
 read.table(pipe(pbpaste),header=TRUE)
   H TQ F
 1 1 2  3.3 a
 2 3 5 10.2 b
 3 5 9 11.0 A
 Warning message: 
 incomplete final line found by readTableHeader on `pbpaste' 
  str(read.table(pipe(pbpaste),header=TRUE))
 `data.frame': 3 obs. of  4 variables:
  $ H: int  1 3 5
  $ T: int  2 5 9
  $ Q: num  3.3 10.2 11
  $ F: Factor w/ 3 levels A,a,b: 2 3 1
 Warning message: 
 incomplete final line found by readTableHeader on `pbpaste'
 
 I haven't been able to track down readTableHeader yet.  The warning
 occurs even without headers in the data. 

I think the Header means the first handful of lines (up to 5) used
to determine the file layout.

FWIW, here's what you can do with oocalc and tcltk on Linux:

 library(tcltk)
 read.delim(textConnection(tclvalue(tcl(clipboard,get
  col1 col2
1   12   NA
2   34   56

OK, so it leaves an open connection dangling, but so does your
pipe()... 

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-16 Thread Uwe Ligges
Werner Wernersen wrote:
Hi!
Is it possible to easily cut  paste data from an
Excel spreadsheet to 
an R edit( ) grid or to variable?
It seems that R cannot handle the cell delimiters
Excel hands over.

Regards,
  Werner
__
R-help@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
copy in Excel and say in R:
read.table(file(clipboard))
Uwe Ligges
__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-16 Thread Peter Dalgaard
Uwe Ligges [EMAIL PROTECTED] writes:

 Werner Wernersen wrote:
 
  Hi!
  Is it possible to easily cut  paste data from an
  Excel spreadsheet to an R edit( ) grid or to variable?
  It seems that R cannot handle the cell delimiters
  Excel hands over.
  Regards,
Werner
  __
  R-help@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
 
 copy in Excel and say in R:
 read.table(file(clipboard))

Er, doesn't that want to be read.delim (or read.delim2 in
comma-locales)? Plain read.table() could cause some grief if there
are empty cells.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-16 Thread Uwe Ligges
Peter Dalgaard wrote:
Uwe Ligges [EMAIL PROTECTED] writes:

Werner Wernersen wrote:

Hi!
Is it possible to easily cut  paste data from an
Excel spreadsheet to an R edit( ) grid or to variable?
It seems that R cannot handle the cell delimiters
Excel hands over.
Regards,
 Werner
__
R-help@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
copy in Excel and say in R:
read.table(file(clipboard))

Er, doesn't that want to be read.delim (or read.delim2 in
comma-locales)? Plain read.table() could cause some grief if there
are empty cells.

Well, yes, some arguments twisting might be required as for my german 
locales / german version of Excel the following works even for empty 
cells and real valued entries:

  read.table(file(clipboard), sep=\t, dec=,)
   V1  V2  V3
1 1.2  NA 2.3
2 3.4 4.5 5.6
Uwe Ligges
__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-16 Thread Peter Dalgaard
Uwe Ligges [EMAIL PROTECTED] writes:

 Well, yes, some arguments twisting might be required as for my german
 locales / german version of Excel the following works even for empty
 cells and real valued entries:
 
read.table(file(clipboard), sep=\t, dec=,)
 
 V1  V2  V3
 1 1.2  NA 2.3
 2 3.4 4.5 5.6

...which is of course the same as 

 read.delim2(file(clipboard), header=FALSE)

except for possible variations in the fill and quote settings. (What
happens if you have empty cells in the last columns, or cells with
the text Don't do this?)

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-16 Thread Uwe Ligges
Peter Dalgaard wrote:
Uwe Ligges [EMAIL PROTECTED] writes:

Well, yes, some arguments twisting might be required as for my german
locales / german version of Excel the following works even for empty
cells and real valued entries:
  read.table(file(clipboard), sep=\t, dec=,)
   V1  V2  V3
1 1.2  NA 2.3
2 3.4 4.5 5.6

...which is of course the same as 

 read.delim2(file(clipboard), header=FALSE)
except for possible variations in the fill and quote settings. (What
happens if you have empty cells in the last columns, or cells with
the text Don't do this?)
Yes, you are right, thanks!
Uwe
__
R-help@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


RE: [R] Easy cut paste from Excel to R?

2005-02-16 Thread Nick Drew
I've had good luck with the scan() function when I
want to get a few numbers from Excel into R quickly to
use it as a calculator. CAVEAT: you have to have the
numbers you want to copy in a column not a row in
Excel. For example:

In Excel your data are in a column as follows:
Col A
1
2
3

Then copy the 3 cells (e.g. 1, 2,3) in Excel and open
R and type in:
 data - scan()

Then Paste using Ctrl-V. Hit the Enter key. You know
have an object called data that you can use and
manipulate in R.

I've taken this even further by creating an R function
that will take a column of numbers from Excel and then
scan() them into R, create a matrix, and then perform
a Chi-square test. Let me know if you'd like to know
more. I'm a beginner and if I can do so can you!!

~Nick

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-16 Thread Gabor Grothendieck
Peter Dalgaard p.dalgaard at biostat.ku.dk writes:

: 
: Uwe Ligges ligges at statistik.uni-dortmund.de writes:
: 
:  Well, yes, some arguments twisting might be required as for my german
:  locales / german version of Excel the following works even for empty
:  cells and real valued entries:
:  
: read.table(file(clipboard), sep=\t, dec=,)
:  
:  V1  V2  V3
:  1 1.2  NA 2.3
:  2 3.4 4.5 5.6
: 
: ...which is of course the same as 
: 
:  read.delim2(file(clipboard), header=FALSE)

which is the same as

   read.delim2(clipboard, header = FALSE)

: 
: except for possible variations in the fill and quote settings. (What
: happens if you have empty cells in the last columns, or cells with
: the text Don't do this?)
:

__
R-help@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


Re: [R] Easy cut paste from Excel to R?

2005-02-16 Thread Werner Wernersen
Thank you all very much for the answers!
The read.table / read.delim2 commands are exactly what
I was looking for to get 
a couple of numbers or a little matrix quickly into R
without creating an extra 
text file every time.

And it works the other way around as well:
write.table(x, file(clipboard), sep=\t)
Fantastic!

Thanks again,
   Werner

Nick Drew wrote:
 I've had good luck with the scan() function when I
 want to get a few numbers from Excel into R quickly
to
 use it as a calculator. CAVEAT: you have to have the
 numbers you want to copy in a column not a row in
 Excel. For example:
 
 In Excel your data are in a column as follows:
 Col A
 1
 2
 3
 
 Then copy the 3 cells (e.g. 1, 2,3) in Excel and
open
 R and type in:
 
data - scan()
 
 
 Then Paste using Ctrl-V. Hit the Enter key. You know
 have an object called data that you can use and
 manipulate in R.
 
 I've taken this even further by creating an R
function
 that will take a column of numbers from Excel and
then
 scan() them into R, create a matrix, and then
perform
 a Chi-square test. Let me know if you'd like to know
 more. I'm a beginner and if I can do so can you!!
 
 ~Nick
 
 
 
   
 __ 
 Do you Yahoo!? 


 http://promotions.yahoo.com/new_mail 
 


__
R-help@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