Tom:
Supposse your Excel file is named "myExcelFile"
Open myExcelFile and SaveAs "myExcelFile.csv" or
"myExcelFile.txt"
Then go to the RConsole and type:
#Option # 1
mydata <- read.csv("PathTomyExcelFile.csv",header=T)
mydata
# You should be able to see your dataset in R
# Option # 2
# If you saved your Excel file as text then you would do:
mydata <-
read.table("PathTomyExcelFile.txt",header=T,sep="\t")
mydata
# Option # 3
# If you want to leave your workbook as Excel file then you
# would need the xlsReadWrite package. and write:
mydata <- read.xls("PathTomyExcelFile")
mydata
# or the easiest one is to download Rcmdr and just click on Data> Import
data
#and select the appropriate file which in this case will be 'from
Excel'
#and just navigate to where your excel file resides. Good luck.
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA
--- On Sat, 10/25/08, Tom Backer Johnsen <backer at psych.uib.no> wrote:
> From: Tom Backer Johnsen <backer at psych.uib.no>
> Subject: Re: [R] Transferring results from R to MS Word
> To: "Jasim Al-Ajmi" <jasimalajmi at gmail.com>,
"r-help at stat.math.ethz.ch" <r-help at stat.math.ethz.ch>
> Date: Saturday, October 25, 2008, 12:05 PM
> Jasim Al-Ajmi wrote:
> > Dear Tom
> > I am a new user of R. My problem is how to read excel
> data files.
> > How can I read a file called stock in R. What
> statement I should use?
> > Thanks for your help.
>
> Thye simplest is to save your file as a .CSV file. This is
> a "plain
> text" file where the elements are separated with
> semicolons or commas.
> The names of the variables (columns) should be in the first
> row of the
> sheet. Look in the documentation for read.table (there are
> other
> alternatives as well).
>
> Call read.table naming your file (or use file.choose())
> setting
> header=T, sep="" to whatever seperates the values
> in your file, and
> na.strings = "" to whatever you identify your
> missing values with.
>
> Tom
> > Best regards
> > Jasim
> > On Fri, Oct 24, 2008 at 10:30 PM, Tom Backer Johnsen
> > <backer at psych.uib.no
> <mailto:backer at psych.uib.no>> wrote:
> >
> > R-users
> >
> > At the moment I am teaching a course on the use of
> R for data
> > analysis. Part of course requirements involves
> the transfer of
> > results from R to something that resembles the APA
> (American
> > Psychological Associations) type tables to MS
> Word. Until now I
> > have used the HTML function in the R2HTML library,
> with a call like
> > this:
> >
> > HTML(summary(model1), file("clipboard",
> "w"), digits=4)
> >
> > Where "model1" is an object containing
> results from a linear model
> > (function lm ()). I have to add that I do not
> remember where I got
> > the digits argument from. The main point is that
> the output is
> > transferred to Excel as the first step where the
> output can be
> > deleted and shuffled in order to produce a
> correctly formatted table
> > according to APA standards which then is
> transferred to MS Word with
> > a copy and paste operation.
> >
> > The problem is simply that what is tranferred to
> Excel varies with
> > what you throw at the HTML function. Nothing is
> rounded of with an
> > lm() model. With a function like sd () I seem to
> consistently get 2
> > decimal points transferred, less than what I want,
> while there are
> > variations in respect to the number of decimals
> when I transfer the
> > result on the summary () using a frame as the
> argument.
> >
> > The optimal thing for me (and the students) would
> be to consistently
> > have all the decimals tranferred to Excel, any
> rounding to could be
> > done there before the transfer of the table to MS
> Word.
> > Alternatively, that something like the argument
> digits=x works in a
> > consistent manner with at least most objects.
> >
> > So:
> >
> > What do I tell my students on what to do using
> R2HTML in order to
> > obtain consistent results?
> >
> > Alternativly: are there other alternatives I and
> my students could
> > use for the transfer of results from R via Excel
> to MS Word?
> >
> > I really would appreciate some suggestions.
> >
> > Tom
> >
> > ______________________________________________
> > R-help at r-project.org
> <mailto: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
> >
> <http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained,
> reproducible code.
> >
> >
>
>
> --
> +----------------------------------------------------------------+
> | Tom Backer Johnsen, Psychometrics Unit, Faculty of
> Psychology |
> | University of Bergen, Christies gt. 12, N-5015 Bergen,
> NORWAY |
> | Tel : +47-5558-9185 Fax :
> +47-5558-9879 |
> | Email : backer at psych.uib.no URL :
> http://www.galton.uib.no/ |
> +----------------------------------------------------------------+
>
> ______________________________________________
> 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.