You should RODBC library. It has some functions to fetch data from excel. You can use the following code
>channel<-odbcConnectExcel("filename.xls") # replace filename with the name of ur file >xldata<-sqlFetch(channel,"excel sheet name", colnames = T) hope this helps Regards, Rana Shoaaib Mehmood On Nov 30, 2007 7:23 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Or even: > > clip <- function() read.delim("clipboard", header = > is.na(suppressWarnings(as.numeric(scan("clipboard", "", 1))))) > > On Nov 29, 2007 7:51 PM, <[EMAIL PROTECTED]> wrote: > > Here is a very crude function I use quite often. It tries to recognize > > whether you have headers or not by checking the very first character. > If > > it is numeric, it assumes that there are no headers. The > suppressWarnings > > gets rid of a warning one gets when trying to coerce a character to > > numeric. The main advantage of the function is that you do not have to > > type too much :-) > > > > clip <- function(){ > > if(is.na(suppressWarnings(as.numeric(scan("clipboard", what="", > > nmax=1))))) > > read.delim("clipboard") > > else > > read.delim("clipboard", header=FALSE) > > > > Cheers, > > > > Andy > > > > __________________________________ > > Andy Jaworski > > 518-1-01 > > Process Laboratory > > 3M Corporate Research Laboratory > > ----- > > E-mail: [EMAIL PROTECTED] > > Tel: (651) 733-6092 > > Fax: (651) 736-3122 > > > > > > > > Bert Gunter > > <[EMAIL PROTECTED] > > ne.com> > To > > Sent by: "'Gabor Grothendieck'" > > [EMAIL PROTECTED] <[EMAIL PROTECTED]> > > project.org > cc > > r-help@r-project.org > > > Subject > > 11/29/2007 06:39 Re: [R] MS Excel Data > > PM > > > > > > > > > > > > > > > > > > > > > > Better yet! Thanks Gabor. > > > > -- Bert > > > > -----Original Message----- > > From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] > > Sent: Thursday, November 29, 2007 12:10 PM > > To: Bert Gunter > > Cc: r-help@r-project.org > > Subject: Re: [R] MS Excel Data > > > > On Nov 29, 2007 3:01 PM, Bert Gunter <[EMAIL PROTECTED]> wrote: > > > This has been discussed on this list many times before. Google on > "Import > > > Excel R". Note also that there are potential problems (loss of digits) > > due > > > to Excel "idiosyncracies" depending on what you do. > > > http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html > > provides > > > some details. > > > > > > Finally, I have found that for rectangular data sets with no missing > > fields > > > in Excel (tables), cutting and read.tabling **the data only ** is a > > > simple(but probably not without risk) way to do it: > > > > > > (after cutting the data only in Excel to the clipboard) in R: > > > > > > newdat <- read.table("clipboard", head=FALSE, row.names=NULL) > > > > > > The columns can then be named via names(newdat) <- ... > > > > > > I omit column headers because in most of the Excel data I get the > column > > > names have spaces and other non-alphanumeric characters which R cannot > > > easily digest. One could separately scan() just the vector of column > > headers > > > and use regular expressions to extract the names. But for small > tables, I > > > find it easier just to create the names manually. > > > > You can include headers with spaces in the copy with: > > > > DF <- read.delim("clipboard") > > > > > > ______________________________________________ > > 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. > > > > > > > > > > ______________________________________________ > 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. > -- Regards, Rana Shoaaib Mehmood (+92) 333 550 4531 [[alternative HTML version deleted]] ______________________________________________ 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.