here is an example that works. all the files are in c:/work/rcomtest
did you forget Chdir? rinterface.RunRFile lokks in EXxcels current directory -------- Macro in Excel workbook Sub ReadTest() rinterface.StartRServer rinterface.RRun "setwd(""c:/work/rcomtest"")" ChDir "c:\work\rcomtest" rinterface.RunRFile "read.R" rinterface.StopRServer rinterface.getdataframe "mydat", Range("Sheet1!A1") End Sub --- read.R setwd("c:/work/rcomtest") mydat<-read.csv("data.txt") --- data.txt xxx1,zzz2 1,2 3,4 5,6 Felipe Carrillo wrote: > Dwayne: > Erich says that read.table should work(see below).I > always include a read.table or read.csv command at the > beginning of my script and always worked as long as I > am running my script through Tinn-R or directly in the > R Console. If read.table doesn't work with a macro > then I will probably stick with Tinn-R directly. > > --- "Lindsay, Dwayne" <[EMAIL PROTECTED]> wrote: > >> Read.table does not work when reading from Excel. >> >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On >> Behalf Of Erich >> Neuwirth >> Sent: Tuesday, August 14, 2007 1:02 PM >> To: R (D)COM and RExcel server related issues >> Subject: Re: [Rcom-l] Excel Macro >> >> show us your read.table command. >> does it have the fiull path with the right kind of >> backlslahes >> or slashes? >> >> Felipe Carrillo wrote: >>> Erich: >>> The code below has a read.table(.....)statement >> and is >>> ignored by R. Can you point out what am I doing >> wrong >>> or if I need additional code? Thanks >>> >>> Sub Testing() >>> Call RInterface.StartRServer >>> Call RInterface.RunRFile("C:\Documents and >>> Settings\Owner\Desktop\R-Software\ATest.r") >>> End Sub >>> >>> >>> >>> --- Erich Neuwirth <[EMAIL PROTECTED]> >>> wrote: >>> >>>> The script can use all R functions >>>> for reading data, >>>> load (for workspaces) >>>> or read.table or >>>> read.spss (from package foreign) >>>> >>>> >>>> Felipe Carrillo wrote: >>>>> Dwayne: >>>>> Thanks a lot for your help,it works fine but for >>>> some >>>>> reason when I try to import a dataset within my >>>> script >>>>> R doesn't execute. It works if I include >> something >>>>> like this in my script: >>>>> set.seed(101) >>>>> gender <- >>>>> factor(x=c(rep("Male",30),rep("Female",70))) >>>>> age.class <- >>>>> > factor(x=rep(c("Y","M","O","Y","M","O"),c(5,15,10,10,40,20)), >>>>> levels=c("Y","M","O")) >>>>> hts <- c(rnorm(30,70,6),rnorm(70,63,4)) >>>>> wts <- >>>>> > c(rnorm(30,80+1.1*hts[1:30],7),rnorm(70,70+0.8*hts[31:70],10)) >>>>> par(mfrow=c(2,2)) >>>>> hist(wts,main="Freq") >>>>> hist(wts,prob=TRUE,main="Prob") >>>>> hist(wts,nclass=4,main="4 bins") >>>>> >> hist(wts,breaks=seq(80,210,by=10),main="Breaks >>>> by >>>>> 10") >>>>> >>>>> Is there a way to import your data into R along >>>> with >>>>> the script or it has to be imported separately? >>>>> Thanks again >>>>> >>>>> --- "Lindsay, Dwayne" <[EMAIL PROTECTED]> wrote: >>>>> >>>>>> Felipe- >>>>>> >>>>>> This is a sample of code that I often use: >>>>>> Call RInterface.RRun(" >> source(""C://temp//Capital >>>>>> Tracking Script.txt"", >>>>>> local = F, chdir = T) ") >>>>>> >>>>>> Where the .txt file is my R-script saved as a >>>> .txt >>>>>> file. I find it a >>>>>> lot easier to do most of my programming in R, >> and >>>>>> use VBA only as an >>>>>> interface for the end-user. It's also easier >> in >>>>>> terms of maintenance. >>>>>> I hope this helps and please let if you need a >>>>>> little more info. >>>>>> >>>>>> Also, 'source' is a R-command that I insert >> into >>>> the >>>>>> RExcel VBA wrapper. >>>>>> Be sure to double up on the: /. For example, R >>>> will >>>>>> execute: >>>>>> source(""C://temp//Capital Tracking >> Script.txt"", >>>>>> local = F, chdir = T), >>>>>> but it will not execute: >> source(""C:/temp/Capital >>>>>> Tracking Script.txt"", >>>>>> local = F, chdir = T) >>>>>> >>>>>> Dwayne >>>>>> >>>>>> -----Original Message----- >>>>>> From: [EMAIL PROTECTED] >>>>>> >> [mailto:[EMAIL PROTECTED] >>>> On >>>>>> Behalf Of Felipe >>>>>> Carrillo >>>>>> Sent: Monday, August 13, 2007 5:37 PM >>>>>> To: rcom-l@mailman.csd.univie.ac.at >>>>>> Subject: [Rcom-l] Excel Macro >>>>>> >>>>>> Hi all: >>>>>> Running the code below in R I am able to create >> a >>>>>> line >>>>>> graph. Is there a way to run the same code from >>>> an >>>>>> Excel macro and get the same results? >>>>>> >>>>>> chinook <- read.table("C:/Documents and >>>>>> Settings/Owner/Desktop/R-Software/chinook.txt", >>>>>> header=T,sep="\t") >>>>>> chinook$IDDate <- as.Date(chinook$IDDate, >>>>>> "%m/%d/%Y") >>>>>> qplot(IDDate,Fry, data=chinook, geom="line") >>>>>> >>>>>> Someone told me about >>>>>> RInterface.RunRFile(filename).Does anyone can >>>> show >>>>>> me >>>>>> how to use it? >>>>>> Thanks >>>>>> >>>>>> >>>>>> >>>>>> Felipe D. Carrillo >>>>>> Fishery Biologist >>>>>> US Fish & Wildlife Service >>>>>> Red Bluff, California 96080 >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> > ________________________________________________________________________ >>>>>> ____________ >>>>>> Sick sense of humor? Visit Yahoo! TV's >>>>>> Comedy with an Edge to see what's on, when. >>>>>> http://tv.yahoo.com/collections/222 >>>>>> _______________________________________________ >>>>>> Rcom-l mailing list >>>>>> Rcom-l@mailman.csd.univie.ac.at >>>>>> > http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l >>>>>> More information (including a Wiki) at >>>>>> http://rcom.univie.ac.at >>>>>> _______________________________________________ >>>>>> Rcom-l mailing list >>>>>> Rcom-l@mailman.csd.univie.ac.at >>>>>> > http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l >>>>>> More information (including a Wiki) at >>>>>> http://rcom.univie.ac.at >>>>>> >>>>> Felipe D. Carrillo >>>>> Fishery Biologist >>>>> US Fish & Wildlife Service >>>>> Red Bluff, California 96080 >>>>> >>>>> >>>>> >>>>> > ________________________________________________________________________ >> ____________ >>>>> Park yourself in front of a world of choices in >>>> alternative vehicles. Visit the Yahoo! Auto Green >>>> Center. >>>>> http://autos.yahoo.com/green_center/ >>>>> _______________________________________________ > === message truncated === > > > Felipe D. Carrillo > Fishery Biologist > US Fish & Wildlife Service > Red Bluff, California 96080 > > > > > ____________________________________________________________________________________ > Sick sense of humor? Visit Yahoo! TV's > Comedy with an Edge to see what's on, when. > http://tv.yahoo.com/collections/222 > _______________________________________________ > Rcom-l mailing list > Rcom-l@mailman.csd.univie.ac.at > http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l > More information (including a Wiki) at http://rcom.univie.ac.at > > -- 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 _______________________________________________ Rcom-l mailing list Rcom-l@mailman.csd.univie.ac.at http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l More information (including a Wiki) at http://rcom.univie.ac.at