Quantcast

how to import data from excel to R

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to import data from excel to R

sta_2279
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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

Richardson, Patrick
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: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
Sent: Thursday, December 17, 2009 12:25 PM
To: [hidden email]
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

______________________________________________
[hidden email] 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}}

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

Joshua Wiley-2
In reply to this post by sta_2279
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, <[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

milton ruser
In reply to this post by sta_2279
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, <[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

David Winsemius
In reply to this post by sta_2279

On Dec 17, 2009, at 11:24 AM, [hidden email] 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

You'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
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

Gabor Grothendieck
In reply to this post by sta_2279
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,  <[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

Sharpie
In reply to this post by sta_2279
On Thu, Dec 17, 2009 at 9:24 AM, <[hidden email]> 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


The "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

______________________________________________
[hidden email] 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.
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

Steve Taylor
Or copy a rectangle of data in Excel, then grab it from the clipboard in R as follows:
 
  my.data <- read.table("clipboard",head=TRUE,sep='\t')
cheers,
   Steve
 

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

shwetank
In reply to this post by sta_2279
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.
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

jholtman
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 <[hidden email]> 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.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to import data from excel to R

Flavio Barros
Simple:

> install.packages('xlsx')
> setwd('C://) (Define directory with your file)
> data <- read.xlsx('file.xlsx', 1) (Read the first spreed sheet)

On Wed, Nov 14, 2012 at 3:25 PM, jim holtman <[hidden email]> wrote:

> 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 <[hidden email]> 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.
> >
> > ______________________________________________
> > [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.
>


--
Att,

Flávio Barros

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.
Loading...