Hi, I am using R and I want to know how data can be transferred from Excel Spread sheet to R for analyzing. I have done like this mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt"); but its not working how can i do it regards Sarath Sankar V Spectrum Softtech Solution
Well, first of all it doesn't look like you're trying to read an excel file as the file you are trying you specify is "data.txt" not "data.xls". Try: library(gdata) ?read.xls HTH, Patrick -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of sta_2279 at spectrum.net.in Sent: Thursday, December 17, 2009 12:25 PM To: r-help at r-project.org Subject: [R] how to import data from excel to R Hi, I am using R and I want to know how data can be transferred from Excel Spread sheet to R for analyzing. I have done like this mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt"); but its not working how can i do it regards Sarath Sankar V Spectrum Softtech Solution ______________________________________________ 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. This email message, including any attachments, is for th...{{dropped:6}}
Hey, If you want to read it in as a text file, make sure to have Excel save it as a text file first. For instance, a tab delimited text file. Then you could read it in with mydata <- read.table("myfile.txt", sep="\t") HTH, Josh On Thu, Dec 17, 2009 at 9:24 AM, <sta_2279@spectrum.net.in> wrote:> Hi, > I am using R and I want to know how data can be transferred from Excel > Spread sheet to R for analyzing. I have done like this > > mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt"); > > > but its not working how can i do it > > regards > > Sarath Sankar V > Spectrum Softtech Solution > > ______________________________________________ > R-help@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. >-- Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/ [[alternative HTML version deleted]]
Hi Sarath, try "C:\\Documents and Settings\\admin\\Desktop\\data.txt" or "C:/Documents and Settings/admin/Desktop/data.txt" or yet setwd("your path") mydata<-read.table("data.txt") cheers miltinho On Thu, Dec 17, 2009 at 12:24 PM, <sta_2279@spectrum.net.in> wrote:> Hi, > I am using R and I want to know how data can be transferred from Excel > Spread sheet to R for analyzing. I have done like this > > mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt"); > > > but its not working how can i do it > > regards > > Sarath Sankar V > Spectrum Softtech Solution > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
On Dec 17, 2009, at 11:24 AM, sta_2279 at spectrum.net.in wrote:> Hi, > I am using R and I want to know how data can be transferred from > Excel > Spread sheet to R for analyzing. I have done like this > > mydata<-read.table("C:\Documents and Settings\admin\Desktop > \data.txt"); > > > but its not working how can i do itYou've gotten three distinct suggestions, all of which are probably needed and none of which would completely fill in the missing aspects of your R-knowledge needed for success: a) reading xls formatted files is possible with quite a few special functions possibly requiring importing packages. b) reading exported tab or comma delimited files is possible. c) your file specification would not have succeeded. d) you did not report the full error message which suggests the you should now read the Posting Guide more thoroughly. e) you should read the documentation in the Import Export Manual. (This is probably also illustrated in several of the introductory manuals, and we expect you to read at least one before posting questions. Do some homework and then you should have an increase in your store of knowledge. -- David.> > regards > > Sarath Sankar V > Spectrum Softtech > Solution > > ______________________________________________ > 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.
Check out these notes: http://wiki.r-project.org/rwiki/doku.php?id=tips:data-io:ms_windows and note that within quotes you must double each backslash so one writes "c:\\mydirectory\\abc.xls" for example. On Thu, Dec 17, 2009 at 12:24 PM, <sta_2279 at spectrum.net.in> wrote:> Hi, > ? I am using R and I want to know how data can be transferred from Excel > Spread sheet to R for analyzing. I have done like this > > mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt"); > > > but its not working how can i do it > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?regards > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Sarath Sankar V > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Spectrum Softtech Solution > > ______________________________________________ > 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. >
On Thu, Dec 17, 2009 at 9:24 AM, <sta_2279 at spectrum.net.in> wrote:> > Hi, > ? I am using R and I want to know how data can be transferred from Excel > Spread sheet to R for analyzing. I have done like this > > mydata<-read.table("C:\Documents and Settings\admin\Desktop\data.txt"); > > > but its not working how can i do itThe "R Data Import/Export" manual covers this topic in general: ??http://cran.r-project.org/doc/manuals/R-data.html Chapter 8 concerns getting data into and out of excel. This post on the Learning R blog also covers many available options for importing directly from Excel files: http://learnr.wordpress.com/2009/10/06/export-data-frames-to-multi-worksheet-excel-file/ Hope this helps! -Charlie
The simplest way, in my opinion is:>save .xls file as .csv in ms excel "save as" option. csv means commadelimited.>now type following command on R console;>mydata<-read.csv(file.choose()) this will open a dialog box will open and select your .csv file. now the data will be saved as "mydata" is actually a data frame. Enjoy, regards. -- View this message in context: http://r.789695.n4.nabble.com/how-to-import-data-from-excel-to-R-tp966629p4649487.html Sent from the R help mailing list archive at Nabble.com.
Also checkout the XLConnect package since it can read/write EXCEL files directly so that you do not have to go through the step of creating a CSV file. Really nice when you want to create an Excel file with multiple worksheets containing different phases of your analysis. On Wed, Nov 14, 2012 at 8:45 AM, shwetank <shwetank at iasri.res.in> wrote:> The simplest way, in my opinion is: >>save .xls file as .csv in ms excel "save as" option. csv means comma > delimited. >>now type following command on R console; > >mydata<-read.csv(file.choose()) > this will open a dialog box will open and select your .csv > file. > now the data will be saved as "mydata" is actually a data frame. > > Enjoy, > regards. > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/how-to-import-data-from-excel-to-R-tp966629p4649487.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.