Quantcast

Read From EXCEL

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

Read From EXCEL

ermimi
Hello!!!

I have been read a much about as read data from Excel File, but I haven´t found the necesary information to read the data.
Now, I can create a channel :  channel <- odbcConnectExcel("file.xls") but I don´t know as read the data??

I hope that you could help me. Thank you very much.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re ad From EXCEL

Erich Neuwirth
To transfer data from Excel to R you have a least 3 options.
RODBC is platform-independent. You can use it to read Excel files
on any platform where you have an ODBC driver for Excel installed.

xlsReadWrite is available only on Windows. It has a function read.xls
which reads data from Excel worksheets into data frames or matrices.
It does not need Excel installed.

RExcel (available through package RExcelInstaller on CRAN)
needs Excel. Among other things, it allows you to select
a range in Excel and transfer it into R through operations
available on additional Excel menus. RExcel not only allows data
transfer, it also allows you to use R function in Excel macros and even
in Excel worksheet functions.

RExcel (and related software) has its own website at
http://rcom.univie.ac.at. It also has its own mailing list
which can be reached through this website.


ermimi wrote:
> Hello!!!
>
> I have been read a much about as read data from Excel File, but I haven´t
> found the necesary information to read the data.
> Now, I can create a channel :  channel <- odbcConnectExcel("file.xls") but I
> don´t know as read the data??
>
> I hope that you could help me. Thank you very much.

--
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

______________________________________________
[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: Re ad From EXCEL

ermimi
Thank you Erich for you information, I will continue investigating about as read data from excel.
Erich Neuwirth wrote
To transfer data from Excel to R you have a least 3 options.
RODBC is platform-independent. You can use it to read Excel files
on any platform where you have an ODBC driver for Excel installed.

xlsReadWrite is available only on Windows. It has a function read.xls
which reads data from Excel worksheets into data frames or matrices.
It does not need Excel installed.

RExcel (available through package RExcelInstaller on CRAN)
needs Excel. Among other things, it allows you to select
a range in Excel and transfer it into R through operations
available on additional Excel menus. RExcel not only allows data
transfer, it also allows you to use R function in Excel macros and even
in Excel worksheet functions.

RExcel (and related software) has its own website at
http://rcom.univie.ac.at. It also has its own mailing list
which can be reached through this website.


ermimi wrote:
> Hello!!!
>
> I have been read a much about as read data from Excel File, but I haven´t
> found the necesary information to read the data.
> Now, I can create a channel :  channel <- odbcConnectExcel("file.xls") but I
> don´t know as read the data??
>
> I hope that you could help me. Thank you very much.

--
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re ad From EXCEL

PIKAL Petr
Hi

there is also a direct copy option

In Excel select a portion of data you want to copy, preferably with header
and press Ctrl-C
Open R
issue

read.delim("clipboard")

For inverse transfer see

?write

Regards

Petr
[hidden email]

[hidden email] napsal dne 20.04.2008 17:51:26:

>
> Thank you Erich for you information, I will continue investigating about
as

> read data from excel.
>
> Erich Neuwirth wrote:
> >
> > To transfer data from Excel to R you have a least 3 options.
> > RODBC is platform-independent. You can use it to read Excel files
> > on any platform where you have an ODBC driver for Excel installed.
> >
> > xlsReadWrite is available only on Windows. It has a function read.xls
> > which reads data from Excel worksheets into data frames or matrices.
> > It does not need Excel installed.
> >
> > RExcel (available through package RExcelInstaller on CRAN)
> > needs Excel. Among other things, it allows you to select
> > a range in Excel and transfer it into R through operations
> > available on additional Excel menus. RExcel not only allows data
> > transfer, it also allows you to use R function in Excel macros and
even

> > in Excel worksheet functions.
> >
> > RExcel (and related software) has its own website at
> > http://rcom.univie.ac.at. It also has its own mailing list
> > which can be reached through this website.
> >
> >
> > ermimi wrote:
> >> Hello!!!
> >>
> >> I have been read a much about as read data from Excel File, but I
haven´t
> >> found the necesary information to read the data.
> >> Now, I can create a channel :  channel <-
odbcConnectExcel("file.xls")

> >> but I
> >> don´t know as read the data??
> >>
> >> I hope that you could help me. Thank you very much.
> >
> > --
> > Erich Neuwirth, University of Vienna
> > Faculty of Computer Science
> > Computer Supported Didactics Working Group
> > Visit our SunSITE at http://sunsite.univie.ac.at
> > Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
> >
> > ______________________________________________
> > [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.
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Read-From-EXCEL-
> tp16787900p16795064.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.

______________________________________________
[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: Re ad From EXCEL

Tom Backer Johnsen
In reply to this post by ermimi
ermimi wrote:
> Hello!!!
>
> I have been read a much about as read data from Excel File, but I haven´t
> found the necesary information to read the data.
> Now, I can create a channel :  channel <- odbcConnectExcel("file.xls") but I
> don´t know as read the data??
>
> I hope that you could help me. Thank you very much.

You are making an attempt at the most complex way of doing this.  The
simplest by far is (a) to read the data from the clipboard with the
read.table () function, or (b) save the spreadsheet as a .csv type file
and use the same function to read the file with the appropriate
arguments for separators etc..  I tend to use the latter approach.

In any case, once imported to R, the frame should be carefully checked
against the contents of the spreadsheet.

Tom

______________________________________________
[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: Re ad From EXCEL - Question

Bert Gunter
In reply to this post by Erich Neuwirth
Erich:

Past posts on this list have pointed out various pros and cons of different
methods of data transer to R from Excel, in particular, loss of precision,
formatting problems, etc. Do you have any comments about to what degree any
of these alternatives may be susceptible or immune from these difficulties?

-- Bert Gunter
Genentech Nonclinical Statistics


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Erich Neuwirth
Sent: Sunday, April 20, 2008 2:18 AM
To: [hidden email]
Subject: Re: [R] Re ad From EXCEL

To transfer data from Excel to R you have a least 3 options.
RODBC is platform-independent. You can use it to read Excel files
on any platform where you have an ODBC driver for Excel installed.

xlsReadWrite is available only on Windows. It has a function read.xls
which reads data from Excel worksheets into data frames or matrices.
It does not need Excel installed.

RExcel (available through package RExcelInstaller on CRAN)
needs Excel. Among other things, it allows you to select
a range in Excel and transfer it into R through operations
available on additional Excel menus. RExcel not only allows data
transfer, it also allows you to use R function in Excel macros and even
in Excel worksheet functions.

RExcel (and related software) has its own website at
http://rcom.univie.ac.at. It also has its own mailing list
which can be reached through this website.


ermimi wrote:
> Hello!!!
>
> I have been read a much about as read data from Excel File, but I haven´t
> found the necesary information to read the data.
> Now, I can create a channel :  channel <- odbcConnectExcel("file.xls") but
I
> don´t know as read the data??
>
> I hope that you could help me. Thank you very much.

--
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

______________________________________________
[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: Re ad From EXCEL

Lucke, Joseph F
In reply to this post by ermimi
fp0 = "C:\\Documents and Settings\\myname\\My Documents\\Research\\"   #upper file path
fp1 = "PIname\\PIproject\\Working00\\"     #middle file path
fp2 = "DateData\\Dates.xls"     #lower file path
dbase = file.path(paste(fp0,fp1,fp2, sep=""))     #create complete file path by paste-ing them together
varList = "ID, ADM_DATE, DISCHARGE_DATE, ICU_DATE, TRANSFER_DATE, READMIT_ICU" #make variable list
varType = c(rep(T,5),F) #I forget what this was for
ch0 = odbcConnectExcel(dbase) #open channel ch0
#odbcGetInfo(ch0) #check for channel infoirmattion
#sqlTables(ch0) #check data information
Dates.data = sqlQuery(ch0, paste("SELECT", varList, "FROM A"), as.is=varType ) #get the data from XL sheet "A" (Here data happens to be dates, another complication, but ignored here)
close(ch0)      #close channel
#data now stored in Dates.data

Joe

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of ermimi
Sent: Saturday, April 19, 2008 5:06 PM
To: [hidden email]
Subject: [R] Re ad From EXCEL


Hello!!!

I have been read a much about as read data from Excel File, but I haven´t found the necesary information to read the data.
Now, I can create a channel :  channel <- odbcConnectExcel("file.xls") but I don´t know as read the data??

I hope that you could help me. Thank you very much.
--
View this message in context: http://www.nabble.com/Read-From-EXCEL-tp16787900p16787900.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.

______________________________________________
[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: Re ad From EXCEL

Jorge I Velez
In reply to this post by ermimi
Hi there,

Try this:

# Function to read data in R from Excel
FromExcel=function(yourfile,spreadsheet){
require(RODBC)
channel=odbcConnectExcel(yourfile)
sqlTables(channel)
mydata=sqlFetch(channel, spreadsheet)
attach(mydata)
mydata
}

mydata=FromExcel("C:/mydata/2008/yourfile.xls","yourspreadsheet")
mydata[1:10,1:10]

"FromExcel" is not as efficient as it could be, but it works for me every
time.


I hope this helps,

Jorge


On Sat, Apr 19, 2008 at 6:06 PM, ermimi <[hidden email]> wrote:

>
> Hello!!!
>
> I have been read a much about as read data from Excel File, but I haven´t
> found the necesary information to read the data.
> Now, I can create a channel :  channel <- odbcConnectExcel("file.xls") but
> I
> don´t know as read the data??
>
> I hope that you could help me. Thank you very much.
> --
> View this message in context:
> http://www.nabble.com/Read-From-EXCEL-tp16787900p16787900.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.
        [[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...