Hi,
I am having a problem reading data between R and Excel. I have saved my code in file: lastsave.txt, and am trying to execute the R commands when the user clicks the command button PA in Excel VBA. I also let the user choose a date (using list box) and one of three options using an option button. The code runs fine when I write the entire R code and try it in Excel. But when I close R and again open the Excel file, it cannot find any of the variables in R. Please find below my code for the command button Private Sub PA_Click() Call RInterface.StartRServer Call RInterface.PutArray("dat", Range("Sheet2!A2")) Call RInterface.RRun("setwd(""D:\Program Files\R\(D)COM Server\xls"")") ChDir "D:\Program Files\R\(D)COM Server\xls" Call RInterface.RunRFile("lastsave.txt") Call RInterface.GetArray("g", Range("Sheet1!C5")) Call RInterface.GetArray("f", Range("Sheet1!D5")) Call RInterface.GetArray("n", Range("Sheet1!E5")) Call RInterface.GetArray("pp_b", Range("Sheet1!F5")) Call RInterface.GetArray("pp_e", Range("Sheet1!G5")) Call RInterface.GetArray("bb_b", Range("Sheet1!H5")) Call RInterface.GetArray("bb_e", Range("Sheet1!I5")) Call RInterface.StopRServer I get the following error in R: Error in as.matrix(g) : object "g" not found Error in as.matrix(f) : object "f" not found Error in as.matrix(n) : object "n" not found Error in as.matrix(pp_b) : object "pp_b" not found Error in as.matrix(pp_e) : object "pp_e" not found Error in as.matrix(bb_b) : object "bb_b" not found Error in as.matrix(bb_e) : object "bb_e" not found I have installed the RDACCSDSetup2040V1.71.exe package. Also, when the user chooses another data and another option, the data does not change and remains the same as the first option. Regards, -Uma This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Any views or opinions presented are solely those of the author and do not necessarily represent those of Amba Holdings Inc., and/or its affiliates. Important additional terms relating to this email can be obtained at http://www.ambaresearch.com/disclaimer
_______________________________________________ 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