Re: [R] How to Import Data

2006-02-22 Thread Petr Pikal
If you do not want to use csv file transfer you can:

Open Excel
select data
Ctrl-C
Open R
your.data - read.delim(clipboard)

will transfer clipboard contents of clipboard into your.data.

HTH
Petr



On 21 Feb 2006 at 8:52, Carl Klarner wrote:

Date sent:  Tue, 21 Feb 2006 08:52:04 -0500
From:   Carl Klarner [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] How to Import Data

 Hello,
 I am a very new user of R.  I've spent several hours trying to import
 data, so I feel okay asking the list for help.  I had an Excel file,
 then I turned it into a csv file, as instructed by directions.  My
 filename is x111.csv.  I then used the following commands to read
 this (fairly small) dataset in.  
 
 x111 -read.table(file='x111.csv',
 sep=,header=T,
 quote=,comment.char=,as.is=T)
 
 I then get the following error message.
 
 Error in file(file, r) : unable to open connection
 In addition: Warning message:
 cannot open file 'x111.csv', reason 'No such file or directory'
 
 I would imagine I'm not putting my csv file in the right location for
 R to be able to read it.  If that's the case, where should I put it? 
 Or is there something else I need to do to it first? Thanks for your
 help, Carl
 
 __
 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


[R] How to Import Data

2006-02-21 Thread Carl Klarner
Hello,
I am a very new user of R.  I've spent several hours trying to import
data, so I feel okay asking the list for help.  I had an Excel file,
then I turned it into a csv file, as instructed by directions.  My
filename is x111.csv.  I then used the following commands to read this
(fairly small) dataset in.  

x111 -read.table(file='x111.csv',
sep=,header=T,
quote=,comment.char=,as.is=T)

I then get the following error message.

Error in file(file, r) : unable to open connection
In addition: Warning message:
cannot open file 'x111.csv', reason 'No such file or directory'

I would imagine I'm not putting my csv file in the right location for R
to be able to read it.  If that's the case, where should I put it?  Or
is there something else I need to do to it first?
Thanks for your help,
Carl

__
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] How to Import Data

2006-02-21 Thread Johann Jacoby
carl,

you wrote:

 I would imagine I'm not putting my csv file in the right location for R
 to be able to read it.  If that's the case, where should I put it?  Or
 is there something else I need to do to it first?

getwd() gives you the working directory in which the datafile has to
reside.

johann

__
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] How to Import Data

2006-02-21 Thread Jacques VESLOT
select the directory with setwd() and then import data:

setwd(d:/.../yourdirectory)
x111 - read.table(x111.csv,...)

or indicate path behind filename:
x111 - read.table(d:/.../yourdirectory/x111.csv,...)

besides, there are other functions to import data.
see ?read.table




Carl Klarner a écrit :

Hello,
I am a very new user of R.  I've spent several hours trying to import
data, so I feel okay asking the list for help.  I had an Excel file,
then I turned it into a csv file, as instructed by directions.  My
filename is x111.csv.  I then used the following commands to read this
(fairly small) dataset in.  

x111 -read.table(file='x111.csv',
sep=,header=T,
quote=,comment.char=,as.is=T)

I then get the following error message.

Error in file(file, r) : unable to open connection
In addition: Warning message:
cannot open file 'x111.csv', reason 'No such file or directory'

I would imagine I'm not putting my csv file in the right location for R
to be able to read it.  If that's the case, where should I put it?  Or
is there something else I need to do to it first?
Thanks for your help,
Carl

__
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] How to Import Data

2006-02-21 Thread Ben Bolker
Carl Klarner cklarner at isugw.indstate.edu writes:

 
 I would imagine I'm not putting my csv file in the right location for R
 to be able to read it.  If that's the case, where should I put it?  Or
 is there something else I need to do to it first?
 Thanks for your help,
 Carl

  You're probably right.  R opens by default in its installation
directory (usually somewhere in Program Files\R\... on Windows)
The easiest thing is to change the working directory to wherever
you have the files using setwd() or (in a GUI) some menu option
(Change dir in the File menu under Windows).

   Useful functions for working directory, file selection etc.:
list.files() [list files in current directory], file.choose() [interactive
file chooser], file.exists() [whether or not a file exists], getwd() [print
current working directory], setwd() [set current working directory].

  The other common problem, which you probably *aren't* having, is
hidden file extensions under Windows.

   good luck
 Ben Bolker

__
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] How to Import Data

2006-02-21 Thread Adaikalavan Ramasamy
1) You need to use sep=, which is appropriate for a CSV file.

2) You need to specify the FULL path to the file. See 
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file

3) You can use read.csv which is the read.table variant for CSV files.


For example

  a - read.csv( file=c:/Progra~1/Docume~1/ramasamy/x111.csv )

might work if you replace it with your full path. If you have the
_unique_ rownames in the first column, you can add the argument
row.names=1 in the call.

Regards, Adai



On Tue, 2006-02-21 at 08:52 -0500, Carl Klarner wrote:
 Hello,
 I am a very new user of R.  I've spent several hours trying to import
 data, so I feel okay asking the list for help.  I had an Excel file,
 then I turned it into a csv file, as instructed by directions.  My
 filename is x111.csv.  I then used the following commands to read this
 (fairly small) dataset in.  
 
 x111 -read.table(file='x111.csv',
 sep=,header=T,
 quote=,comment.char=,as.is=T)
 
 I then get the following error message.
 
 Error in file(file, r) : unable to open connection
 In addition: Warning message:
 cannot open file 'x111.csv', reason 'No such file or directory'
 
 I would imagine I'm not putting my csv file in the right location for R
 to be able to read it.  If that's the case, where should I put it?  Or
 is there something else I need to do to it first?
 Thanks for your help,
 Carl
 
 __
 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] How to Import Data

2006-02-21 Thread Aleš Žiberna
Or, you should put the whole path to that file, for example

file='C:/My documents/x111.csv'

Best,
Ales Ziberna


Johann Jacoby pravi:
 carl,

 you wrote:

   
 I would imagine I'm not putting my csv file in the right location for R
 to be able to read it.  If that's the case, where should I put it?  Or
 is there something else I need to do to it first?
 

 getwd() gives you the working directory in which the datafile has to
 reside.

 johann

 __
 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] How to Import Data

2006-02-21 Thread Philipp Pagel
On Tue, Feb 21, 2006 at 08:52:04AM -0500, Carl Klarner wrote:

 x111 -read.table(file='x111.csv',
 sep=,header=T,
 quote=,comment.char=,as.is=T)

to make things easier for you you could do

x111 -read.table( file.choose(), ... )

Also: Why are you setting sep= ? Your filename suggests that you have
some kind of separator in your file...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
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] How to Import Data

2006-02-21 Thread Duncan Murdoch
On 2/21/2006 9:13 AM, Adaikalavan Ramasamy wrote:
 1) You need to use sep=, which is appropriate for a CSV file.
 
 2) You need to specify the FULL path to the file. See 
 http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file

The advice to look at the FAQ is good, but it's not true that you need 
the full path.  Like other programs, R maintains a current working 
directory, and paths can be specified relative to that.  I usually put a 
line like

setwd('c:/my/working/dir')

at the start of scripts, so that the current directory is changed from 
the beginning.  Then I can use simple filenames to read files.

The other advice I usually give is to specify file.choose() instead of 
an explicit filename; this will open a file selection dialog.  (In my 
opinion, this should be the default, but some people disagree quite 
strongly.)

Duncan Murdoch

 
 3) You can use read.csv which is the read.table variant for CSV files.
 
 
 For example
 
   a - read.csv( file=c:/Progra~1/Docume~1/ramasamy/x111.csv )
 
 might work if you replace it with your full path. If you have the
 _unique_ rownames in the first column, you can add the argument
 row.names=1 in the call.
 
 Regards, Adai
 
 
 
 On Tue, 2006-02-21 at 08:52 -0500, Carl Klarner wrote:
 Hello,
 I am a very new user of R.  I've spent several hours trying to import
 data, so I feel okay asking the list for help.  I had an Excel file,
 then I turned it into a csv file, as instructed by directions.  My
 filename is x111.csv.  I then used the following commands to read this
 (fairly small) dataset in.  
 
 x111 -read.table(file='x111.csv',
 sep=,header=T,
 quote=,comment.char=,as.is=T)
 
 I then get the following error message.
 
 Error in file(file, r) : unable to open connection
 In addition: Warning message:
 cannot open file 'x111.csv', reason 'No such file or directory'
 
 I would imagine I'm not putting my csv file in the right location for R
 to be able to read it.  If that's the case, where should I put it?  Or
 is there something else I need to do to it first?
 Thanks for your help,
 Carl
 
 __
 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

__
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] How to import data as numeric array?

2005-06-28 Thread tong wang
Did some search but couldn't find useful result.

I am trying to read a n*m dimension data with read.table,  what i need is a 
numeric array, 
is there any efficient way to allow me get this array directly instead of a 
list? 
I tried to use as.array() to change the mode, but seems it doesn't work and i 
got this error message:

Error in dimnames-.data.frame(`*tmp*`, value = list(function (M)  : 
invalid dimnames given for data frame 
 
what's wrong with the dimension names , should i delete them? how can i do that?

Thanks a lot for any help.

tong wang

__
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] How to import data as numeric array?

2005-06-28 Thread Prof Brian Ripley
Please consult the `R Data Import/Export Manual'.  You could be using 
scan(), as in

   matrix(scan(some_file, 0), nrow=n, byrow=TRUE)

On Tue, 28 Jun 2005, tong wang wrote:

 Did some search but couldn't find useful result.

 I am trying to read a n*m dimension data with read.table, what i need is 
 a numeric array, is there any efficient way to allow me get this array 
 directly instead of a list? I tried to use as.array() to change the 
 mode, but seems it doesn't work and i got this error message:

 Error in dimnames-.data.frame(`*tmp*`, value = list(function (M)  :
invalid dimnames given for data frame 

 what's wrong with the dimension names , should i delete them? how can i do 
 that?

I think you wanted as.matrix here, not as.array: probably the call to the 
latter was incorrect, but we were not shown it.

-- 
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] How to import data as numeric array?

2005-06-28 Thread ronggui
maybe you can use the array function,like
array(CO2,dim(CO2),list(rownames(CO2),colnames(CO2)))
and matrix is just a specif type of array,so maybe you can use as.matrix
as.matrix(CO2)

the above tow,the CO2 is a data.frame which can use read.table to read in.

the third way is:use the scan the read the data and use array to change the 
data to array.


On Tue, 28 Jun 2005 01:05:23 -0700
tong wang [EMAIL PROTECTED] wrote:

 Did some search but couldn't find useful result.
 
 I am trying to read a n*m dimension data with read.table,  what i need is a 
 numeric array, 
 is there any efficient way to allow me get this array directly instead of a 
 list? 
 I tried to use as.array() to change the mode, but seems it doesn't work and i 
 got this error message:
 
 Error in dimnames-.data.frame(`*tmp*`, value = list(function (M)  : 
 invalid dimnames given for data frame 
  
 what's wrong with the dimension names , should i delete them? how can i do 
 that?
 
 Thanks a lot for any help.
 
 tong wang
 
 __
 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


-- 
Department of Sociology
Fudan University,Shanghai
Blog:http://sociology.yculblog.com

__
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