Dear all,
I appologise for cluttering up the list with such a basic question,
however I have been unable to find the answer I want (possibly through
my poor usage of the R help system).
As I am visually impaired and using assistive technology, I think I
would prefer to use R from the terminal mode, i.e. by running rterm.exe
found in the bin directory.
I have managed to set my working directory, I know this as typing
getwd() returns
u:/copd/r
which is the directory I want. In this directory is a file named
InitialDataAnalysis.csv
which I would like to read in to R. However, I am simply unable to find
the surely simple command to do this. Just typing
InitialDataAnalysis.csv reports "object not found" etc, as does
read.file("InitialDataAnalysis.csv") etc. I am surely making a simple
mistake? Please could someone tell me how to read this file in to the
terminal window?
I know the file is in the directory and in the correct format as I am
able to open it successfully in the R GUI, in this environment the file
works properly, I can subset it, make dataframes etc, but as I say I
would like to be able to do this in the terminal rather than the GUI.
I am new to R so please have patients with this request.
Many thanks for any help,
Robin.
Robin Williams
Met Office summer intern - Health Forecasting
robin.williams@metoffice.gov.uk
[[alternative HTML version deleted]]
Maybe the spelling is slightly differently than you think. List all filenames ending in csv: dir(patt = "csv$") If there is only one then: fn <- dir(patt = "csv$") read.csv(fn) or if there are many and its the second read.csv(fn[2]) On Tue, Jul 22, 2008 at 9:24 AM, Williams, Robin <robin.williams at metoffice.gov.uk> wrote:> Dear all, > I appologise for cluttering up the list with such a basic question, > however I have been unable to find the answer I want (possibly through > my poor usage of the R help system). > As I am visually impaired and using assistive technology, I think I > would prefer to use R from the terminal mode, i.e. by running rterm.exe > found in the bin directory. > I have managed to set my working directory, I know this as typing > getwd() returns > u:/copd/r > which is the directory I want. In this directory is a file named > InitialDataAnalysis.csv > which I would like to read in to R. However, I am simply unable to find > the surely simple command to do this. Just typing > InitialDataAnalysis.csv reports "object not found" etc, as does > read.file("InitialDataAnalysis.csv") etc. I am surely making a simple > mistake? Please could someone tell me how to read this file in to the > terminal window? > I know the file is in the directory and in the correct format as I am > able to open it successfully in the R GUI, in this environment the file > works properly, I can subset it, make dataframes etc, but as I say I > would like to be able to do this in the terminal rather than the GUI. > I am new to R so please have patients with this request. > Many thanks for any help, > Robin. > > > Robin Williams > Met Office summer intern - Health Forecasting > robin.williams at metoffice.gov.uk > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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. >
Hi Robin,
Look at ?read.csv and ?read.table
Regards,
Ruan
Ruan Rossouw
Sasol Technology R&D
Reaction Technology and Industrial Statistics
Tel: +27 16 960 4717
Fax: +27 11 522 4465
Cell: +27 83 724 4163
e-mail: Ruan.Rossouw at Sasol.Com
[All views expressed are my own and not necessarily that of my
employer.]
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Williams, Robin
Sent: 22 July 2008 03:25 PM
To: r-help at r-project.org
Subject: [R] Opening files from R terminal - appologies
Dear all,
I appologise for cluttering up the list with such a basic question,
however I have been unable to find the answer I want (possibly through
my poor usage of the R help system).
As I am visually impaired and using assistive technology, I think I
would prefer to use R from the terminal mode, i.e. by running rterm.exe
found in the bin directory.
I have managed to set my working directory, I know this as typing
getwd() returns
u:/copd/r
which is the directory I want. In this directory is a file named
InitialDataAnalysis.csv which I would like to read in to R. However, I
am simply unable to find the surely simple command to do this. Just
typing InitialDataAnalysis.csv reports "object not found" etc, as does
read.file("InitialDataAnalysis.csv") etc. I am surely making a simple
mistake? Please could someone tell me how to read this file in to the
terminal window?
I know the file is in the directory and in the correct format as I am
able to open it successfully in the R GUI, in this environment the file
works properly, I can subset it, make dataframes etc, but as I say I
would like to be able to do this in the terminal rather than the GUI.
I am new to R so please have patients with this request.
Many thanks for any help,
Robin.
Robin Williams
Met Office summer intern - Health Forecasting
robin.williams at metoffice.gov.uk
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org 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.
----------------------------------------------------------------------------
NOTICE: Please note that this eMail, and the contents thereof,
is subject to the standard Sasol eMail legal notice which may be found at:
http://www.sasol.com/legalnotices
If you cannot access the legal notice through the URL attached and you wish
to receive a copy thereof please send an eMail to
legalnotice at sasol.com
----------------------------------------------------------------------------
Hi Robin,
read.table() is the general import function, and read.csv() and read.csv2() are
very similar but have different defaults.
For learning the ins and outs of R, the keyword help search is very useful:
help.search("csv") would have sent you to read.table for data input.
There are also some useful reference materials available at www.r-project.org
that cover the basics, including data import and export.
Sarah
On Tue, Jul 22, 2008 at 9:24 AM, Williams, Robin
<robin.williams at metoffice.gov.uk> wrote:
In this directory is a file named> InitialDataAnalysis.csv
> which I would like to read in to R. However, I am simply unable to find
> the surely simple command to do this. Just typing
> InitialDataAnalysis.csv reports "object not found" etc, as does
> read.file("InitialDataAnalysis.csv") etc. I am surely making a
simple
> mistake? Please could someone tell me how to read this file in to the
> terminal window?
--
Sarah Goslee
http://www.functionaldiversity.org
What I suggest you do is
1) Put the R bin directory in your path.
2) cd to your working directory, and start Rterm.exe from there.
3) Then
dat <- read.csv("InitialDataAnalysis.csv")
should work. Note, there is no 'read.file', and of the many read.*
functions you want to read a .csv file so it is read.csv you want.
On Tue, 22 Jul 2008, Williams, Robin wrote:
> Dear all,
> I appologise for cluttering up the list with such a basic question,
> however I have been unable to find the answer I want (possibly through
> my poor usage of the R help system).
> As I am visually impaired and using assistive technology, I think I
> would prefer to use R from the terminal mode, i.e. by running rterm.exe
> found in the bin directory.
> I have managed to set my working directory, I know this as typing
> getwd() returns
> u:/copd/r
> which is the directory I want. In this directory is a file named
> InitialDataAnalysis.csv
> which I would like to read in to R. However, I am simply unable to find
> the surely simple command to do this. Just typing
> InitialDataAnalysis.csv reports "object not found" etc, as does
> read.file("InitialDataAnalysis.csv") etc. I am surely making a
simple
> mistake? Please could someone tell me how to read this file in to the
> terminal window?
> I know the file is in the directory and in the correct format as I am
> able to open it successfully in the R GUI, in this environment the file
> works properly, I can subset it, make dataframes etc, but as I say I
> would like to be able to do this in the terminal rather than the GUI.
If you follow my 1) and 2), this should work exactly like using Rgui.exe.
> I am new to R so please have patients with this request.
> Many thanks for any help,
> Robin.
>
>
> Robin Williams
> Met Office summer intern - Health Forecasting
> robin.williams at metoffice.gov.uk
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
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, UK Fax: +44 1865 272595