Mike Hilt
2012-May-09 22:38 UTC
[R] Can't read xlsx file into R. Seem, Seem to have XLConnect loaded.
I have spent hours on R in Windows 7. Just installed 2 days ago so the R package should be current. Currently I am using the RGui (64-bit) for Windows. I can not read an Excel file into R from my computer. Have hours on this. Completely crazy!! I have the XLConnect package loaded. I think it is loaded because when I enter:> loadedNamespaces()[1] "base" "datasets" "graphics" "grDevices" [5] "methods" "rJava" "stats" "tools" [9] "utils" "XLConnect" "XLConnectJars" XLConnect is listed. Does that mean it is loaded?> getwd()[1] "F:/RwkCB3/R OG SBCD 1205v01"> list.files()[1] "~$ R OG SBCD 1205 MH1.docx" "~WRL2121.tmp" [3] "01 R OG SBCD 1205 MH1 BU1.docx" "01 R OG SBCD 1205 MH1.docx" [5] "01 R OG SBCD 1205v01 BU2" "Dta1.txt" [7] "Gas Dly YTD1204 v01 BU.xlsm" "Gas Dly YTD1204 v01.xlsm" [9] "Oil Dly YTD1204 v01 BU.xlsm" "Oil Dly YTD1204 v01.xlsm" [11] "Oil Dly YTD1204 v01.xlsx" "R OG SBCD 1205v01 sCt.lnk" [13] "R setwd to C Prog R sCt OtDt.lnk" So apparently "Oil Dly YTD1204 v01.xlsx" exists in my working directory. SO WHY DOES THE FOLLOWING BEHAVE THE WAY IT DOES?> OlPrcFl <- loadWorkbook(“Oil Dly YTD1204 v01.xlsx”, create = FALSE)Error: unexpected input in "OlPrcFl <- loadWorkbook(“" I can read an xlsx file in when I do:> OlPrcFl <- loadWorkbook(file.choose())That is not a real, long-term solution. Have same problem installing packages -- Can't get R to load a package when I specify a path. Works when I use file.choose() I would really appreciate it if you could tell me what is going on. Thanks, Mike Hilt mikehilt21@gmail.com [[alternative HTML version deleted]]
Jim Holtman
2012-May-10 01:44 UTC
[R] Can't read xlsx file into R. Seem, Seem to have XLConnect loaded.
does your quoted filename have "smart" quotes? are you using WORD to create your scripts? Sent from my iPad On May 9, 2012, at 18:38, Mike Hilt <mikehilt21 at gmail.com> wrote:> I have spent hours on R in Windows 7. Just installed 2 days ago so the R > package should be current. > > > > Currently I am using the RGui (64-bit) for Windows. > > > > I can not read an Excel file into R from my computer. Have hours on this. > Completely crazy!! > > > > I have the XLConnect package loaded. I think it is loaded because when I > enter: > > > >> loadedNamespaces() > > [1] "base" "datasets" "graphics" "grDevices" > > [5] "methods" "rJava" "stats" "tools" > > [9] "utils" "XLConnect" "XLConnectJars" > > > > XLConnect is listed. Does that mean it is loaded? > > > >> getwd() > > [1] "F:/RwkCB3/R OG SBCD 1205v01" > > >> list.files() > > [1] "~$ R OG SBCD 1205 MH1.docx" "~WRL2121.tmp" > > [3] "01 R OG SBCD 1205 MH1 BU1.docx" "01 R OG SBCD 1205 MH1.docx" > > [5] "01 R OG SBCD 1205v01 BU2" "Dta1.txt" > > [7] "Gas Dly YTD1204 v01 BU.xlsm" "Gas Dly YTD1204 v01.xlsm" > > [9] "Oil Dly YTD1204 v01 BU.xlsm" "Oil Dly YTD1204 v01.xlsm" > > [11] "Oil Dly YTD1204 v01.xlsx" "R OG SBCD 1205v01 sCt.lnk" > > [13] "R setwd to C Prog R sCt OtDt.lnk" > > > > So apparently "Oil Dly YTD1204 v01.xlsx" exists in my working directory. > > > > SO WHY DOES THE FOLLOWING BEHAVE THE WAY IT DOES? > > > >> OlPrcFl <- loadWorkbook(?Oil Dly YTD1204 v01.xlsx?, create = FALSE) > > Error: unexpected input in "OlPrcFl <- loadWorkbook(?" > > > > > I can read an xlsx file in when I do: > > >> OlPrcFl <- loadWorkbook(file.choose()) > > That is not a real, long-term solution. > > > Have same problem installing packages -- Can't get R to load a package when > I specify a path. Works when I use file.choose() > > > > > I would really appreciate it if you could tell me what is going on. > > > > Thanks, > > Mike Hilt > > mikehilt21 at gmail.com > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.
David Winsemius
2012-May-10 01:44 UTC
[R] Can't read xlsx file into R. Seem, Seem to have XLConnect loaded.
On May 9, 2012, at 6:38 PM, Mike Hilt wrote:> I have spent hours on R in Windows 7. Just installed 2 days ago so > the R > package should be current. Currently I am using the RGui (64-bit) > for Windows. > > I can not read an Excel file into R from my computer. Have hours on > this. > Completely crazy!! >snipped rant.> > So apparently "Oil Dly YTD1204 v01.xlsx" exists in my working > directory. > > SO WHY DOES THE FOLLOWING BEHAVE THE WAY IT DOES? > >> OlPrcFl <- loadWorkbook(?Oil Dly YTD1204 v01.xlsx?, create = FALSE)Most likely you need to quote that file argument. At the moment the interpreter is probably trying to find an object named "Oil" in your workspace. Try OlPrcFl <- loadWorkbook("?Oil Dly YTD1204 v01.xlsx"?, create = FALSE)> > Error: unexpected input in "OlPrcFl <- loadWorkbook(?" > > I can read an xlsx file in when I do: > > >> OlPrcFl <- loadWorkbook(file.choose()) > > That is not a real, long-term solution. > > > Have same problem installing packages -- Can't get R to load a > package when > I specify a path.Probably the same error, failing to quote when R expects to a character object.> Works when I use file.choose() > > [[alternative HTML version deleted]]Sigh. I _know_ that gmail will allow you to post in plain text. -- David Winsemius, MD West Hartford, CT
Peter Alspach
2012-May-10 01:46 UTC
[R] Can't read xlsx file into R. Seem, Seem to have XLConnect loaded.
Tena koe Mike To possibilities spring to mind: 1. loadedNamespaces() doesn't necessarily give you a list of the packages on the search path. Try search() instead. 2. It appears you may be using Word's so-called smart quotes. Note the difference in the error alert: Error: unexpected input in "OlPrcFl <- loadWorkbook("". I'm guessing it is the " which is causing problems, although I haven't used the XLConnect package. HTH ..... Peter Alspach -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Mike Hilt Sent: Thursday, 10 May 2012 10:38 a.m. To: r-help at r-project.org Subject: [R] Can't read xlsx file into R. Seem, Seem to have XLConnect loaded. I have spent hours on R in Windows 7. Just installed 2 days ago so the R package should be current. Currently I am using the RGui (64-bit) for Windows. I can not read an Excel file into R from my computer. Have hours on this. Completely crazy!! I have the XLConnect package loaded. I think it is loaded because when I enter:> loadedNamespaces()[1] "base" "datasets" "graphics" "grDevices" [5] "methods" "rJava" "stats" "tools" [9] "utils" "XLConnect" "XLConnectJars" XLConnect is listed. Does that mean it is loaded?> getwd()[1] "F:/RwkCB3/R OG SBCD 1205v01"> list.files()[1] "~$ R OG SBCD 1205 MH1.docx" "~WRL2121.tmp" [3] "01 R OG SBCD 1205 MH1 BU1.docx" "01 R OG SBCD 1205 MH1.docx" [5] "01 R OG SBCD 1205v01 BU2" "Dta1.txt" [7] "Gas Dly YTD1204 v01 BU.xlsm" "Gas Dly YTD1204 v01.xlsm" [9] "Oil Dly YTD1204 v01 BU.xlsm" "Oil Dly YTD1204 v01.xlsm" [11] "Oil Dly YTD1204 v01.xlsx" "R OG SBCD 1205v01 sCt.lnk" [13] "R setwd to C Prog R sCt OtDt.lnk" So apparently "Oil Dly YTD1204 v01.xlsx" exists in my working directory. SO WHY DOES THE FOLLOWING BEHAVE THE WAY IT DOES?> OlPrcFl <- loadWorkbook("Oil Dly YTD1204 v01.xlsx", create = FALSE)Error: unexpected input in "OlPrcFl <- loadWorkbook("" I can read an xlsx file in when I do:> OlPrcFl <- loadWorkbook(file.choose())That is not a real, long-term solution. Have same problem installing packages -- Can't get R to load a package when I specify a path. Works when I use file.choose() I would really appreciate it if you could tell me what is going on. Thanks, Mike Hilt mikehilt21 at gmail.com [[alternative HTML version deleted]] The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited.
Martin Studer
2012-May-10 18:01 UTC
[R] Can't read xlsx file into R. Seem, Seem to have XLConnect loaded.
Hi Mike, as others have already suggested, there might be a problem with quoting. Otherwise, did you already have a look at the package vignette ( http://cran.r-project.org/web/packages/XLConnect/vignettes/XLConnect.pdf http://cran.r-project.org/web/packages/XLConnect/vignettes/XLConnect.pdf ) that gives a number of examples on how to read/write Excel files? Best regards, Martin -- View this message in context: http://r.789695.n4.nabble.com/Can-t-read-xlsx-file-into-R-Seem-Seem-to-have-XLConnect-loaded-tp4622229p4624156.html Sent from the R help mailing list archive at Nabble.com.